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
- 
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.org.springframework.core.task.SimpleAsyncTaskExecutorbuild()Build a newSimpleAsyncTaskExecutorinstance and configure it using this builder.<T extends org.springframework.core.task.SimpleAsyncTaskExecutor>
 TBuild a newSimpleAsyncTaskExecutorinstance of the specified type and configure it using this builder.concurrencyLimit(Integer concurrencyLimit) Set the concurrency limit.<T extends org.springframework.core.task.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.rejectTasksWhenLimitReached(boolean rejectTasksWhenLimitReached) Set whether to reject tasks when the concurrency limit has been reached.taskDecorator(org.springframework.core.task.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
 
- 
rejectTasksWhenLimitReachedpublic SimpleAsyncTaskExecutorBuilder rejectTasksWhenLimitReached(boolean rejectTasksWhenLimitReached) Set whether to reject tasks when the concurrency limit has been reached. By defaultfalseto block the caller until the submission can be accepted. Switch totruefor immediate rejection instead.- Parameters:
- rejectTasksWhenLimitReached- whether to reject tasks when the concurrency limit has been reached
- Returns:
- a new builder instance
- Since:
- 3.5.0
 
- 
concurrencyLimitSet the concurrency limit.- Parameters:
- concurrencyLimit- the concurrency limit
- Returns:
- a new builder instance
 
- 
taskDecoratorpublic SimpleAsyncTaskExecutorBuilder taskDecorator(org.springframework.core.task.TaskDecorator taskDecorator) Set 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:
 
- 
buildpublic org.springframework.core.task.SimpleAsyncTaskExecutor build()Build a newSimpleAsyncTaskExecutorinstance and configure it using this builder.- Returns:
- a configured SimpleAsyncTaskExecutorinstance.
- See Also:
 
- 
buildpublic <T extends org.springframework.core.task.SimpleAsyncTaskExecutor> T build(Class<T> taskExecutorClass) Build 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:
 
- 
configurepublic <T extends org.springframework.core.task.SimpleAsyncTaskExecutor> T configure(T taskExecutor) Configure 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:
 
 
-