Interface AsyncTaskExecutor
- All Superinterfaces:
Executor, TaskExecutor
- All Known Subinterfaces:
SchedulingTaskExecutor
- All Known Implementing Classes:
ConcurrentTaskExecutor, ConcurrentTaskScheduler, DefaultManagedTaskExecutor, DefaultManagedTaskScheduler, SimpleAsyncTaskExecutor, SimpleAsyncTaskScheduler, SimpleThreadPoolTaskExecutor, TaskExecutorAdapter, ThreadPoolTaskExecutor, ThreadPoolTaskScheduler, VirtualThreadTaskExecutor
Extended interface for asynchronous
TaskExecutor implementations,
offering support for Future/CompletableFuture handles.
Implementing this interface also indicates that the TaskExecutor.execute(Runnable)
method will not execute the given Runnable in the caller's thread but rather
asynchronously in some other thread.
- Since:
- 2.0.3
- Author:
- Juergen Hoeller
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final longDeprecated.static final longDeprecated.along withexecute(Runnable, long) -
Method Summary
Modifier and TypeMethodDescriptiondefault voidDeprecated.since the common executors do not support start timeoutsdefault Future<?> Submit a Runnable task for execution, receiving a Future representing that task.Submit a Callable task for execution, receiving a Future representing that task.default CompletableFuture<Void> submitCompletable(Runnable task) Submit aRunnabletask for execution, receiving aCompletableFuturerepresenting that task.default <T extends @Nullable Object>
CompletableFuture<T> submitCompletable(Callable<T> task) Submit aCallabletask for execution, receiving aCompletableFuturerepresenting that task.Methods inherited from interface TaskExecutor
execute
-
Field Details
-
TIMEOUT_IMMEDIATE
Deprecated.along withexecute(Runnable, long)Constant that indicates immediate execution.- See Also:
-
TIMEOUT_INDEFINITE
-
-
Method Details
-
execute
Deprecated.since the common executors do not support start timeoutsExecute the giventask.As of 6.1, this method comes with a default implementation that simply delegates to
TaskExecutor.execute(Runnable), ignoring the timeout completely.- Parameters:
task- theRunnableto execute (nevernull)startTimeout- the time duration (milliseconds) within which the task is supposed to start. This is intended as a hint to the executor, allowing for preferred handling of immediate tasks. Typical values areTIMEOUT_IMMEDIATEorTIMEOUT_INDEFINITE(the default as used byTaskExecutor.execute(Runnable)).- Throws:
TaskTimeoutException- in case of the task being rejected because of the timeout (i.e. it cannot be started in time)TaskRejectedException- if the given task was not accepted- See Also:
-
submit
Submit a Runnable task for execution, receiving a Future representing that task. The Future will return anullresult upon completion.As of 6.1, this method comes with a default implementation that delegates to
TaskExecutor.execute(Runnable).- Parameters:
task- theRunnableto execute (nevernull)- Returns:
- a Future representing pending completion of the task
- Throws:
TaskRejectedException- if the given task was not accepted- Since:
- 3.0
-
submit
Submit a Callable task for execution, receiving a Future representing that task. The Future will return the Callable's result upon completion.As of 6.1, this method comes with a default implementation that delegates to
TaskExecutor.execute(Runnable).- Parameters:
task- theCallableto execute (nevernull)- Returns:
- a Future representing pending completion of the task
- Throws:
TaskRejectedException- if the given task was not accepted- Since:
- 3.0
-
submitCompletable
Submit aRunnabletask for execution, receiving aCompletableFuturerepresenting that task. The Future will return anullresult upon completion.- Parameters:
task- theRunnableto execute (nevernull)- Returns:
- a
CompletableFuturerepresenting pending completion of the task - Throws:
TaskRejectedException- if the given task was not accepted- Since:
- 6.0
-
submitCompletable
Submit aCallabletask for execution, receiving aCompletableFuturerepresenting that task. The Future will return the Callable's result upon completion.- Parameters:
task- theCallableto execute (nevernull)- Returns:
- a
CompletableFuturerepresenting pending completion of the task - Throws:
TaskRejectedException- if the given task was not accepted- Since:
- 6.0
-
execute(Runnable, long)