java.lang.Object | ||
↳ | java.util.concurrent.AbstractExecutorService | |
↳ | com.facebook.common.executors.CallerThreadExecutor |
An executor service that runs each task in the thread that invokes execute/submit
.
This applies both to individually submitted tasks and to collections of tasks submitted via
invokeAll
or invokeAny
. In the latter case, tasks will run serially on the
calling thread. Tasks are run to completion before a Future
is returned to the caller.
The implementation deviates from the ExecutorService
specification with regards to the
shutdownNow
and awaitTermination
methods. 1. A call to shutdown
or shutdownNow
is a no-op. A call to isTerminated
always returns false. 2. A call to awaitTermination
always returns true immediately. True is returned in order to avoid potential
infinite loop in the clients. 3. "best-effort" with regards to canceling running tasks is
implemented as "no-effort". No interrupts or other attempts are made to stop threads executing
tasks. 4. The returned list will always be empty, as any submitted task is considered to have
started execution. This applies also to tasks given to invokeAll
or invokeAny
which are pending serial execution, including the tasks that have not yet started execution.
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
boolean | awaitTermination(long timeout, TimeUnit unit) | ||||||||||
void | execute(Runnable command) | ||||||||||
static CallerThreadExecutor | getInstance() | ||||||||||
boolean | isShutdown() | ||||||||||
boolean | isTerminated() | ||||||||||
void | shutdown() | ||||||||||
List<Runnable> | shutdownNow() |
[Expand]
Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
From class
java.util.concurrent.AbstractExecutorService
| |||||||||||
From class
java.lang.Object
| |||||||||||
From interface
java.util.concurrent.Executor
| |||||||||||
From interface
java.util.concurrent.ExecutorService
|
InterruptedException |
---|