Package org.springframework.core.task
Interface TaskExecutor
- All Superinterfaces:
Executor
- All Known Subinterfaces:
AsyncListenableTaskExecutor,AsyncTaskExecutor
- All Known Implementing Classes:
SimpleAsyncTaskExecutor,SyncTaskExecutor,TaskExecutorAdapter,VirtualThreadTaskExecutor
- Functional Interface:
- This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.
Simple task executor interface that abstracts the execution
of a
Runnable.
Implementations can use all sorts of different execution strategies, such as: synchronous, asynchronous, using a thread pool, and more.
Equivalent to Java's Executor interface,
so that clients may declare a dependency on an Executor and receive
any TaskExecutor implementation. This interface remains separate from
the standard Executor interface primarily for backwards compatibility
with older APIs that depend on the TaskExecutor interface.
- Since:
- 2.0
- Author:
- Juergen Hoeller
- See Also:
-
Method Summary
-
Method Details
-
execute
Execute the giventask.The call might return immediately if the implementation uses an asynchronous execution strategy, or might block in the case of synchronous execution.
- Specified by:
executein interfaceExecutor- Parameters:
task- theRunnableto execute (nevernull)- Throws:
TaskRejectedException- if the given task was not accepted
-