Java.util.concurrent.Executor interface with Examples Last Updated : 24 Sep, 2021 Comments Improve Suggest changes Like Article Like Report The concurrent API in Java provides a feature known as an executor that initiates and controls the execution of threads. As such, an executor offers an alternative to managing threads using the thread class. At the core of an executor is the Executor interface. It refers to the objects that execute submitted Runnable tasks. Class hierarchy: java.util.concurrent ↳ Interface Executor Implementing Sub-Interfaces: ExecutorService ScheduledExecutorService Implementing Classes: AbstractExecutorService ForkJoinPool ScheduledThreadPoolExecutor ThreadPoolExecutor Methods in Executor interface: execute(): This function executes the given command at some time in the future. The command may execute in a new thread, in a pooled thread, or in the calling thread, at the discretion of the Executor implementation.Syntax: void execute(Runnable task) Example to demonstrate an Executor. Java import java.util.concurrent.Executor; import java.util.concurrent.RejectedExecutionException; public class ExecutorDemo { public static void main(String[] args) { ExecutorImp obj = new ExecutorImp(); try { obj.execute(new NewThread()); } catch (RejectedExecutionException | NullPointerException exception) { System.out.println(exception); } } } class ExecutorImp implements Executor { @Override public void execute(Runnable command) { new Thread(command).start(); } } class NewThread implements Runnable { @Override public void run() { System.out.println("Thread executed under an executor"); } } Output: Thread executed under an executor Reference:https://docs.oracle.com/javase/9/docs/api/java/util/concurrent/Executor.html Comment More infoAdvertise with us Next Article Java.util.concurrent.Executor interface with Examples C CharchitKapoor Follow Improve Article Tags : Java Practice Tags : Java Similar Reads Java.util.concurrent.ExecutorService Interface with Examples The ExecutorService interface extends Executor by adding methods that help manage and control the execution of threads. It is defined in java.util.concurrent package. It defines methods that execute the threads that return results, a set of threads that determine the shutdown status. The ExecutorSer 3 min read Java.util.concurrent.Exchanger class with Examples Exchanger is the most interesting synchronization class of Java. It facilitates the exchange of elements between a pair of threads by creating a synchronization point. It simplifies the exchange of data between two threads. Its operation is simple: it simply waits until two separate threads call its 3 min read Java.util.concurrent.Phaser class in Java with Examples Phaser's primary purpose is to enable synchronization of threads that represent one or more phases of activity. It lets us define a synchronization object that waits until a specific phase has been completed. It then advances to the next phase until that phase concludes. It can also be used to synch 7 min read ConcurrentMap Interface in Java The ConcurrentMap Interface is part of the Java Collections Framework and was introduced in JDK 1.5. It is designed for thread-safe concurrent access to its entries without compromising the consistency of the map. The interface resides in the java.util.concurrent package and extends the Map interfac 9 min read ConcurrentSkipListMap in Java with Examples The ConcurrentSkipListMap class is a member of the Java Collections Framework. It was introduced in JDK 1.6, it belongs to java.util.concurrent package. The ConcurrentSkipListMap is a scalable implementation of ConcurrentNavigableMap. All the elements are sorted based on natural ordering or by the C 10 min read Like