public interface

AsyncTaskExecutor

implements TaskExecutor
org.springframework.core.task.AsyncTaskExecutor
Known Indirect Subclasses

Class Overview

Extended interface for asynchronous TaskExecutor implementations, offering an overloaded execute(Runnable, long) variant with a start timeout parameter as well support for java.util.concurrent.Callable.

Note: The java.util.concurrent.Executors class includes a set of methods that can convert some other common closure-like objects, for example, java.security.PrivilegedAction to Callable before executing them.

Implementing this interface also indicates that the execute(Runnable) method will not execute its Runnable in the caller's thread but rather asynchronously in some other thread.

See Also

Summary

Constants
long TIMEOUT_IMMEDIATE Constant that indicates immediate execution
long TIMEOUT_INDEFINITE Constant that indicates no time limit
Public Methods
abstract void execute(Runnable task, long startTimeout)
Execute the given task.
abstract <T> Future<T> submit(Callable<T> task)
Submit a Callable task for execution, receiving a Future representing that task.
abstract Future<?> submit(Runnable task)
Submit a Runnable task for execution, receiving a Future representing that task.
[Expand]
Inherited Methods
From interface java.util.concurrent.Executor
From interface org.springframework.core.task.TaskExecutor

Constants

public static final long TIMEOUT_IMMEDIATE

Also: SpringCore

Constant that indicates immediate execution

Constant Value: 0 (0x0000000000000000)

public static final long TIMEOUT_INDEFINITE

Also: SpringCore

Constant that indicates no time limit

Constant Value: 9223372036854775807 (0x7fffffffffffffff)

Public Methods

public abstract void execute (Runnable task, long startTimeout)

Also: SpringCore

Execute the given task.

Parameters
task the Runnable to execute (never null)
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 are TIMEOUT_IMMEDIATE or TIMEOUT_INDEFINITE (the default as used by 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

public abstract Future<T> submit (Callable<T> task)

Also: SpringCore

Submit a Callable task for execution, receiving a Future representing that task. The Future will return the Callable's result upon completion.

Parameters
task the Callable to execute (never null)
Returns
  • a Future representing pending completion of the task
Throws
TaskRejectedException if the given task was not accepted

public abstract Future<?> submit (Runnable task)

Also: SpringCore

Submit a Runnable task for execution, receiving a Future representing that task. The Future will return a null result upon completion.

Parameters
task the Runnable to execute (never null)
Returns
  • a Future representing pending completion of the task
Throws
TaskRejectedException if the given task was not accepted