org.springframework.core.task.TaskExecutor
and exposes a full java.util.concurrent.ExecutorService for it.
This is primarily for adapting to client components that communicate via the
java.util.concurrent.ExecutorService API. It can also be used as
common ground between a local Spring TaskExecutor backend and a
JNDI-located ManagedExecutorService in a Jakarta EE environment.
Note
This ExecutorService adapter does not support the
lifecycle methods in the java.util.concurrent.ExecutorService API
("shutdown()" etc.), similar to a server-wide ManagedExecutorService
in a Jakarta EE environment. The lifecycle is always up to the backend pool,
with this adapter acting as an access-only proxy for that target pool.
java.util.concurrent.ExecutorService
| Modifier and Type | Field and Description |
|---|---|
| private final TaskExecutor |
| Access | Constructor and Description |
|---|---|
| public | ExecutorServiceAdapter(TaskExecutor
the target executor to delegate to taskExecutor)Create a new ExecutorServiceAdapter, using the given target executor. |
| Modifier and Type | Method and Description |
|---|---|
| public boolean | awaitTermination(long
the maximum time to wait timeout, TimeUnit the time unit of the timeout argument unit)Implements java. Blocks until all tasks have completed execution after a shutdown request, or the timeout occurs, or the current thread is interrupted, whichever happens first. |
| public void | close()
Overrides default java. Initiates an orderly shutdown in which previously submitted tasks are executed, but no new tasks will be accepted. |
| public void | execute(Runnable
the runnable task task)Implements java. Executes the given command at some time in the future. |
| public boolean | isShutdown()
Implements java. Returns |
| public boolean | isTerminated()
Implements java. Returns |
| public void | shutdown()
Implements java. Initiates an orderly shutdown in which previously submitted tasks are executed, but no new tasks will be accepted. |
| public List | shutdownNow()
Implements java. Attempts to stop all actively executing tasks, halts the processing of waiting tasks, and returns a list of the tasks that were awaiting execution. |
| taskExecutor | back to summary |
|---|---|
| private final TaskExecutor taskExecutor | |
| ExecutorServiceAdapter | back to summary |
|---|---|
| public ExecutorServiceAdapter(TaskExecutor taskExecutor) Create a new ExecutorServiceAdapter, using the given target executor.
| |
| awaitTermination | back to summary |
|---|---|
| public boolean awaitTermination(long timeout, TimeUnit unit) throws InterruptedException Implements java. Doc from java. Blocks until all tasks have completed execution after a shutdown request, or the timeout occurs, or the current thread is interrupted, whichever happens first.
| |
| close | back to summary |
|---|---|
| public void close() Overrides default java. Doc from java. Initiates an orderly shutdown in which previously submitted tasks are executed, but no new tasks will be accepted. This method waits until all tasks have completed execution and the executor has terminated. If interrupted while waiting, this method stops all executing tasks as
if by invoking If already terminated, invoking this method has no effect. | |
| execute | back to summary |
|---|---|
| public void execute(Runnable task) Implements java. Doc from java. 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 | |
| isShutdown | back to summary |
|---|---|
| public boolean isShutdown() Implements java. Doc from java. Returns
| |
| isTerminated | back to summary |
|---|---|
| public boolean isTerminated() Implements java. Doc from java. Returns
| |
| shutdown | back to summary |
|---|---|
| public void shutdown() Implements java. Doc from java. Initiates an orderly shutdown in which previously submitted tasks are executed, but no new tasks will be accepted. Invocation has no additional effect if already shut down. This method does not wait for previously submitted tasks to
complete execution. Use
| |
| shutdownNow | back to summary |
|---|---|
| public List Implements java. Doc from java. Attempts to stop all actively executing tasks, halts the processing of waiting tasks, and returns a list of the tasks that were awaiting execution. This method does not wait for actively executing tasks to
terminate. Use There are no guarantees beyond best-effort attempts to stop
processing actively executing tasks. For example, typical
implementations will cancel via | |