An Executor that provides methods to manage termination. An ExecutorService can be shut down, which will cause it to stop accepting new tasks. After being shut down, the executor will eventually terminate, at which point no tasks are actively executing, no tasks are awaiting execution, and no new tasks can be submitted.
The Executors
class provides factory methods for the
executor services provided in this package.
Method Summary | |
---|---|
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. |
boolean |
isShutdown()
Returns true if this executor has been shut down. |
boolean |
isTerminated()
Returns true if all tasks have completed following shut down. |
void |
shutdown()
Initiates an orderly shutdown in which previously submitted tasks are executed, but no new tasks will be accepted. |
List |
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. |
Methods inherited from interface java.util.concurrent.Executor |
---|
execute |
Method Detail |
---|
void shutdown()
List shutdownNow()
There are no guarantees beyond best-effort attempts to stop
processing actively executing tasks. For example, typical
implementations will cancel via Thread.interrupt()
, so if any
tasks mask or fail to respond to interrupts, they may never terminate.
boolean isShutdown()
boolean isTerminated()
boolean awaitTermination(long timeout, TimeUnit unit) throws InterruptedException
timeout
- the maximum time to waitunit
- the time unit of the timeout argument
InterruptedException
- if interrupted while waiting