接口 AsyncTaskExecutor
- 所有超级接口:
Executor
,TaskExecutor
- 所有已知实现类:
ConcurrentTaskExecutor
,ConcurrentTaskScheduler
,DefaultManagedTaskExecutor
,DefaultManagedTaskScheduler
,SimpleAsyncTaskExecutor
,SimpleThreadPoolTaskExecutor
,TaskExecutorAdapter
,ThreadPoolTaskExecutor
,ThreadPoolTaskScheduler
,WorkManagerTaskExecutor
,WorkManagerTaskExecutor
public interface AsyncTaskExecutor extends TaskExecutor
Extended interface for asynchronousTaskExecutor
implementations, offering an overloadedexecute(Runnable, long)
variant with a start timeout parameter as well support forCallable
.Note: The
Executors
class includes a set of methods that can convert some other common closure-like objects, for example,PrivilegedAction
toCallable
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.- 从以下版本开始:
- 2.0.3
- 作者:
- Juergen Hoeller
- 另请参阅:
SimpleAsyncTaskExecutor
,SchedulingTaskExecutor
,Callable
,Executors
字段概要
字段 修饰符和类型 字段 说明 static long
TIMEOUT_IMMEDIATE
Constant that indicates immediate execution.static long
TIMEOUT_INDEFINITE
Constant that indicates no time limit.
方法概要
所有方法 实例方法 抽象方法 修饰符和类型 方法 说明 void
execute(Runnable task, long startTimeout)
Execute the giventask
.Future<?>
submit(Runnable task)
Submit a Runnable task for execution, receiving a Future representing that task.<T> Future<T>
submit(Callable<T> task)
Submit a Callable task for execution, receiving a Future representing that task.从接口继承的方法 org.springframework.core.task.TaskExecutor
execute
字段详细资料
TIMEOUT_IMMEDIATE
static final long TIMEOUT_IMMEDIATE
Constant that indicates immediate execution.- 另请参阅:
- 常量字段值
TIMEOUT_INDEFINITE
static final long TIMEOUT_INDEFINITE
Constant that indicates no time limit.- 另请参阅:
- 常量字段值
方法详细资料
execute
void execute(Runnable task, long startTimeout)
Execute the giventask
.- 参数:
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)
).- 抛出:
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
Future<?> submit(Runnable task)
Submit a Runnable task for execution, receiving a Future representing that task. The Future will return anull
result upon completion.- 参数:
task
- theRunnable
to execute (nevernull
)- 返回:
- a Future representing pending completion of the task
- 抛出:
TaskRejectedException
- if the given task was not accepted- 从以下版本开始:
- 3.0
submit
<T> Future<T> submit(Callable<T> task)
Submit a Callable task for execution, receiving a Future representing that task. The Future will return the Callable's result upon completion.- 参数:
task
- theCallable
to execute (nevernull
)- 返回:
- a Future representing pending completion of the task
- 抛出:
TaskRejectedException
- if the given task was not accepted- 从以下版本开始:
- 3.0