java.lang.Object | ||
↳ | org.springframework.util.CustomizableThreadCreator | |
↳ | org.springframework.core.task.SimpleAsyncTaskExecutor |
TaskExecutor
implementation that fires up a new Thread for each task,
executing it asynchronously.
Supports limiting concurrent threads through the "concurrencyLimit" bean property. By default, the number of concurrent threads is unlimited.
NOTE: This implementation does not reuse threads! Consider a thread-pooling TaskExecutor implementation instead, in particular for executing a large number of short-lived tasks.
Constants | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
int | NO_CONCURRENCY | Switch concurrency 'off': that is, don't allow any concurrent invocations. | |||||||||
int | UNBOUNDED_CONCURRENCY | Permit any number of concurrent invocations: that is, don't throttle concurrency. |
[Expand]
Inherited Constants | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
From interface
org.springframework.core.task.AsyncTaskExecutor
|
Public Constructors | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Create a new SimpleAsyncTaskExecutor with default thread name prefix.
| |||||||||||
Create a new SimpleAsyncTaskExecutor with the given thread name prefix.
| |||||||||||
Create a new SimpleAsyncTaskExecutor with the given external thread factory.
|
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Executes the given task, within a concurrency throttle
if configured (through the superclass's settings).
| |||||||||||
Executes the given task, within a concurrency throttle
if configured (through the superclass's settings).
| |||||||||||
Return the maximum number of parallel accesses allowed.
| |||||||||||
Return the external factory to use for creating new Threads, if any.
| |||||||||||
Return whether this throttle is currently active.
| |||||||||||
Set the maximum number of parallel accesses allowed.
| |||||||||||
Specify an external factory to use for creating new Threads,
instead of relying on the local properties of this executor.
| |||||||||||
Submit a Callable task for execution, receiving a Future representing that task.
| |||||||||||
Submit a Runnable task for execution, receiving a Future representing that task.
|
Protected Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Template method for the actual execution of a task.
|
[Expand]
Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
From class
org.springframework.util.CustomizableThreadCreator
| |||||||||||
From class
java.lang.Object
| |||||||||||
From interface
java.util.concurrent.Executor
| |||||||||||
From interface
org.springframework.core.task.AsyncTaskExecutor
| |||||||||||
From interface
org.springframework.core.task.TaskExecutor
|
Switch concurrency 'off': that is, don't allow any concurrent invocations.
Permit any number of concurrent invocations: that is, don't throttle concurrency.
Create a new SimpleAsyncTaskExecutor with default thread name prefix.
Create a new SimpleAsyncTaskExecutor with the given thread name prefix.
threadNamePrefix | the prefix to use for the names of newly created threads |
---|
Create a new SimpleAsyncTaskExecutor with the given external thread factory.
threadFactory | the factory to use for creating new Threads |
---|
Executes the given task, within a concurrency throttle if configured (through the superclass's settings).
Executes urgent tasks (with 'immediate' timeout) directly, bypassing the concurrency throttle (if active). All other tasks are subject to throttling.
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) ). |
Executes the given task, within a concurrency throttle if configured (through the superclass's settings).
task | the Runnable to execute (never null ) |
---|
Return the maximum number of parallel accesses allowed.
Return the external factory to use for creating new Threads, if any.
Return whether this throttle is currently active.
true
if the concurrency limit for this instance is activeSet the maximum number of parallel accesses allowed. -1 indicates no concurrency limit at all.
In principle, this limit can be changed at runtime, although it is generally designed as a config time setting. NOTE: Do not switch between -1 and any concrete limit at runtime, as this will lead to inconsistent concurrency counts: A limit of -1 effectively turns off concurrency counting completely.
Specify an external factory to use for creating new Threads, instead of relying on the local properties of this executor.
You may specify an inner ThreadFactory bean or also a ThreadFactory reference obtained from JNDI (on a Java EE 6 server) or some other lookup mechanism.
Submit a Callable task for execution, receiving a Future representing that task. The Future will return the Callable's result upon completion.
task | the Callable to execute (never null ) |
---|
Submit a Runnable task for execution, receiving a Future representing that task.
The Future will return a null
result upon completion.
task | the Runnable to execute (never null ) |
---|
Template method for the actual execution of a task.
The default implementation creates a new Thread and starts it.
task | the Runnable to execute |
---|