Package org.springframework.core.task
Interface AsyncTaskExecutor
- All Superinterfaces:
Executor
,TaskExecutor
- All Known Subinterfaces:
AsyncListenableTaskExecutor
,SchedulingTaskExecutor
- All Known Implementing Classes:
ConcurrentTaskExecutor
,ConcurrentTaskScheduler
,DefaultManagedTaskExecutor
,DefaultManagedTaskScheduler
,SimpleAsyncTaskExecutor
,SimpleThreadPoolTaskExecutor
,TaskExecutorAdapter
,ThreadPoolTaskExecutor
,ThreadPoolTaskScheduler
Extended interface for asynchronous
TaskExecutor
implementations,
offering an overloaded execute(Runnable, long)
variant with a start
timeout parameter as well support for Callable
.
Note: The Executors
class includes a set of
methods that can convert some other common closure-like objects, for example,
PrivilegedAction
to Callable
before executing them.
Implementing this interface also indicates that the TaskExecutor.execute(Runnable)
method will not execute its 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 long
Constant that indicates immediate execution.static final long
Constant that indicates no time limit. -
Method Summary
Methods inherited from interface org.springframework.core.task.TaskExecutor
execute
-
Field Details
-
TIMEOUT_IMMEDIATE
static final long TIMEOUT_IMMEDIATEConstant that indicates immediate execution.- See Also:
-
TIMEOUT_INDEFINITE
static final long TIMEOUT_INDEFINITEConstant that indicates no time limit.- See Also:
-
-
Method Details
-
execute
Execute the giventask
.- Parameters:
task
- theRunnable
to 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_IMMEDIATE
orTIMEOUT_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
-
submit
Submit a Runnable task for execution, receiving a Future representing that task. The Future will return anull
result upon completion.- Parameters:
task
- theRunnable
to 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.- Parameters:
task
- theCallable
to execute (nevernull
)- Returns:
- a Future representing pending completion of the task
- Throws:
TaskRejectedException
- if the given task was not accepted- Since:
- 3.0
-