Package org.springframework.boot.task
Class SimpleAsyncTaskExecutorBuilder
java.lang.Object
org.springframework.boot.task.SimpleAsyncTaskExecutorBuilder
Builder that can be used to configure and create a
SimpleAsyncTaskExecutor
.
Provides convenience methods to set common SimpleAsyncTaskExecutor
settings and
register taskDecorator(TaskDecorator)
). For advanced configuration, consider
using SimpleAsyncTaskExecutorCustomizer
.
In a typical auto-configured Spring Boot application this builder is available as a
bean and can be injected whenever a SimpleAsyncTaskExecutor
is needed.
- Since:
- 3.2.0
- Author:
- Stephane Nicoll, Filip Hrisafov, Moritz Halbritter
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionadditionalCustomizers
(Iterable<? extends SimpleAsyncTaskExecutorCustomizer> customizers) Addcustomizers
that should be applied to theSimpleAsyncTaskExecutor
.additionalCustomizers
(SimpleAsyncTaskExecutorCustomizer... customizers) Addcustomizers
that should be applied to theSimpleAsyncTaskExecutor
.build()
Build a newSimpleAsyncTaskExecutor
instance and configure it using this builder.<T extends SimpleAsyncTaskExecutor>
TBuild a newSimpleAsyncTaskExecutor
instance of the specified type and configure it using this builder.concurrencyLimit
(Integer concurrencyLimit) Set the concurrency limit.<T extends SimpleAsyncTaskExecutor>
Tconfigure
(T taskExecutor) Configure the providedSimpleAsyncTaskExecutor
instance using this builder.customizers
(Iterable<? extends SimpleAsyncTaskExecutorCustomizer> customizers) Set thecustomizers
that should be applied to theSimpleAsyncTaskExecutor
.customizers
(SimpleAsyncTaskExecutorCustomizer... customizers) Set thecustomizers
that should be applied to theSimpleAsyncTaskExecutor
.taskDecorator
(TaskDecorator taskDecorator) Set theTaskDecorator
to use ornull
to not use any.threadNamePrefix
(String threadNamePrefix) Set the prefix to use for the names of newly created threads.virtualThreads
(Boolean virtualThreads) Set whether to use virtual threads.
-
Constructor Details
-
SimpleAsyncTaskExecutorBuilder
public SimpleAsyncTaskExecutorBuilder()
-
-
Method Details
-
threadNamePrefix
Set the prefix to use for the names of newly created threads.- Parameters:
threadNamePrefix
- the thread name prefix to set- Returns:
- a new builder instance
-
virtualThreads
Set whether to use virtual threads.- Parameters:
virtualThreads
- whether to use virtual threads- Returns:
- a new builder instance
-
concurrencyLimit
Set the concurrency limit.- Parameters:
concurrencyLimit
- the concurrency limit- Returns:
- a new builder instance
-
taskDecorator
Set theTaskDecorator
to use ornull
to not use any.- Parameters:
taskDecorator
- the task decorator to use- Returns:
- a new builder instance
-
customizers
Set thecustomizers
that should be applied to theSimpleAsyncTaskExecutor
. Customizers are applied in the order that they were added after builder configuration has been applied. Setting this value will replace any previously configured customizers.- Parameters:
customizers
- the customizers to set- Returns:
- a new builder instance
- See Also:
-
customizers
public SimpleAsyncTaskExecutorBuilder customizers(Iterable<? extends SimpleAsyncTaskExecutorCustomizer> customizers) Set thecustomizers
that should be applied to theSimpleAsyncTaskExecutor
. Customizers are applied in the order that they were added after builder configuration has been applied. Setting this value will replace any previously configured customizers.- Parameters:
customizers
- the customizers to set- Returns:
- a new builder instance
- See Also:
-
additionalCustomizers
public SimpleAsyncTaskExecutorBuilder additionalCustomizers(SimpleAsyncTaskExecutorCustomizer... customizers) Addcustomizers
that should be applied to theSimpleAsyncTaskExecutor
. Customizers are applied in the order that they were added after builder configuration has been applied.- Parameters:
customizers
- the customizers to add- Returns:
- a new builder instance
- See Also:
-
additionalCustomizers
public SimpleAsyncTaskExecutorBuilder additionalCustomizers(Iterable<? extends SimpleAsyncTaskExecutorCustomizer> customizers) Addcustomizers
that should be applied to theSimpleAsyncTaskExecutor
. Customizers are applied in the order that they were added after builder configuration has been applied.- Parameters:
customizers
- the customizers to add- Returns:
- a new builder instance
- See Also:
-
build
Build a newSimpleAsyncTaskExecutor
instance and configure it using this builder.- Returns:
- a configured
SimpleAsyncTaskExecutor
instance. - See Also:
-
build
Build a newSimpleAsyncTaskExecutor
instance of the specified type and configure it using this builder.- Type Parameters:
T
- the type of task executor- Parameters:
taskExecutorClass
- the template type to create- Returns:
- a configured
SimpleAsyncTaskExecutor
instance. - See Also:
-
configure
Configure the providedSimpleAsyncTaskExecutor
instance using this builder.- Type Parameters:
T
- the type of task executor- Parameters:
taskExecutor
- theSimpleAsyncTaskExecutor
to configure- Returns:
- the task executor instance
- See Also:
-