the methods supported by various types of Executor in Java:
Executor Type | Supported Methods |
---|---|
SingleThreadExecutor | execute(Runnable command) |
CachedThreadPool | execute(Runnable command) |
submit(Runnable task) | |
submit(Callable<T> task) | |
shutdown() | |
shutdownNow() | |
isShutdown() | |
isTerminated() | |
awaitTermination(long timeout, TimeUnit unit) | |
FixedThreadPool | execute(Runnable command) |
submit(Runnable task) | |
submit(Callable<T> task) | |
shutdown() | |
shutdownNow() | |
isShutdown() | |
isTerminated() | |
awaitTermination(long timeout, TimeUnit unit) | |
ScheduledThreadPoolExecutor | schedule(Runnable command, long delay, TimeUnit unit) |
schedule(Callable<V> callable, long delay, TimeUnit unit) | |
scheduleAtFixedRate(Runnable command, long initialDelay, long period, TimeUnit unit) | |
scheduleWithFixedDelay(Runnable command, long initialDelay, long delay, TimeUnit unit) | |
execute(Runnable command) | |
submit(Runnable task) | |
submit(Callable<T> task) | |
shutdown() | |
shutdownNow() | |
isShutdown() | |
isTerminated() | |
awaitTermination(long timeout, TimeUnit unit) |
Note that this table is not exhaustive and does not cover all methods supported by every type of Executor.
ExecutorService supported methods:
supported methods of the ExecutorService interface in Java:
Method | Description |
---|---|
void execute(Runnable command) | Executes the given command at some time in the future. |
Future<?> submit(Runnable task) | Submits a Runnable task for execution and returns a Future representing that task. |
<T> Future<T> submit(Callable<T> task) | Submits a Callable task for execution and returns a Future representing that task. |
<T> List<Future<T>> invokeAll(Collection<? extends Callable<T>> tasks) | Executes the given tasks, returning a list of Futures holding their status and results when all complete. |
<T> List<Future<T>> invokeAll(Collection<? extends Callable<T>> tasks, long timeout, TimeUnit unit) | Executes the given tasks, returning a list of Futures holding their status and results when all complete or the timeout expires. |
<T> T invokeAny(Collection<? extends Callable<T>> tasks) | Executes the given tasks, returning the result of one that has completed successfully. |
<T> T invokeAny(Collection<? extends Callable<T>> tasks, long timeout, TimeUnit unit) | Executes the given tasks, returning the result of one that has completed successfully or cancelling all tasks if the timeout expires. |
boolean isShutdown() | Returns true if this executor has been shut down. |
boolean isTerminated() | Returns true if all tasks have completed following shut down. |
boolean awaitTermination(long timeout, TimeUnit unit) | Blocks until all tasks have completed execution after a shutdown request, or the timeout occurs, or the current thread is interrupted, whichever happens first. |
void shutdown() | Initiates an orderly shutdown in which previously submitted tasks are executed, but no new tasks will be accepted. |
List<Runnable> shutdownNow() | Attempts to stop all actively executing tasks, halts the processing of waiting tasks, and returns a list of the tasks that were awaiting execution. |