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 SummaryConstructors
- 
Method SummaryModifier and TypeMethodDescriptionadditionalCustomizers(Iterable<? extends SimpleAsyncTaskExecutorCustomizer> customizers) Addcustomizersthat should be applied to theSimpleAsyncTaskExecutor.additionalCustomizers(SimpleAsyncTaskExecutorCustomizer... customizers) Addcustomizersthat should be applied to theSimpleAsyncTaskExecutor.build()Build a newSimpleAsyncTaskExecutorinstance and configure it using this builder.<T extends SimpleAsyncTaskExecutor>
 TBuild a newSimpleAsyncTaskExecutorinstance 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 providedSimpleAsyncTaskExecutorinstance using this builder.customizers(Iterable<? extends SimpleAsyncTaskExecutorCustomizer> customizers) Set thecustomizersthat should be applied to theSimpleAsyncTaskExecutor.customizers(SimpleAsyncTaskExecutorCustomizer... customizers) Set thecustomizersthat should be applied to theSimpleAsyncTaskExecutor.taskDecorator(TaskDecorator taskDecorator) Set theTaskDecoratorto use ornullto not use any.taskTerminationTimeout(Duration taskTerminationTimeout) Set the task termination timeout.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- 
SimpleAsyncTaskExecutorBuilderpublic SimpleAsyncTaskExecutorBuilder()
 
- 
- 
Method Details- 
threadNamePrefixSet the prefix to use for the names of newly created threads.- Parameters:
- threadNamePrefix- the thread name prefix to set
- Returns:
- a new builder instance
 
- 
virtualThreadsSet whether to use virtual threads.- Parameters:
- virtualThreads- whether to use virtual threads
- Returns:
- a new builder instance
 
- 
concurrencyLimitSet the concurrency limit.- Parameters:
- concurrencyLimit- the concurrency limit
- Returns:
- a new builder instance
 
- 
taskDecoratorSet theTaskDecoratorto use ornullto not use any.- Parameters:
- taskDecorator- the task decorator to use
- Returns:
- a new builder instance
 
- 
taskTerminationTimeoutSet the task termination timeout.- Parameters:
- taskTerminationTimeout- the task termination timeout
- Returns:
- a new builder instance
- Since:
- 3.2.1
 
- 
customizersSet thecustomizersthat 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:
 
- 
customizerspublic SimpleAsyncTaskExecutorBuilder customizers(Iterable<? extends SimpleAsyncTaskExecutorCustomizer> customizers) Set thecustomizersthat 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:
 
- 
additionalCustomizerspublic SimpleAsyncTaskExecutorBuilder additionalCustomizers(SimpleAsyncTaskExecutorCustomizer... customizers) Addcustomizersthat 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:
 
- 
additionalCustomizerspublic SimpleAsyncTaskExecutorBuilder additionalCustomizers(Iterable<? extends SimpleAsyncTaskExecutorCustomizer> customizers) Addcustomizersthat 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:
 
- 
buildBuild a newSimpleAsyncTaskExecutorinstance and configure it using this builder.- Returns:
- a configured SimpleAsyncTaskExecutorinstance.
- See Also:
 
- 
buildBuild a newSimpleAsyncTaskExecutorinstance 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 SimpleAsyncTaskExecutorinstance.
- See Also:
 
- 
configureConfigure the providedSimpleAsyncTaskExecutorinstance using this builder.- Type Parameters:
- T- the type of task executor
- Parameters:
- taskExecutor- the- SimpleAsyncTaskExecutorto configure
- Returns:
- the task executor instance
- See Also:
 
 
-