Package org.springframework.boot.task
Class SimpleAsyncTaskSchedulerBuilder
java.lang.Object
org.springframework.boot.task.SimpleAsyncTaskSchedulerBuilder
Builder that can be used to configure and create a
SimpleAsyncTaskScheduler
.
Provides convenience methods to set common SimpleAsyncTaskScheduler
settings.
For advanced configuration, consider using SimpleAsyncTaskSchedulerCustomizer
.
In a typical auto-configured Spring Boot application this builder is available as a
bean and can be injected whenever a SimpleAsyncTaskScheduler
is needed.
- Since:
- 3.2.0
- Author:
- Stephane Nicoll, Moritz Halbritter
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionadditionalCustomizers
(Iterable<? extends SimpleAsyncTaskSchedulerCustomizer> customizers) AddthreadPoolTaskSchedulerCustomizers
that should be applied to theSimpleAsyncTaskScheduler
.additionalCustomizers
(SimpleAsyncTaskSchedulerCustomizer... customizers) AddthreadPoolTaskSchedulerCustomizers
that should be applied to theSimpleAsyncTaskScheduler
.build()
Build a newSimpleAsyncTaskScheduler
instance and configure it using this builder.concurrencyLimit
(Integer concurrencyLimit) Set the concurrency limit.<T extends SimpleAsyncTaskScheduler>
Tconfigure
(T taskScheduler) Configure the providedSimpleAsyncTaskScheduler
instance using this builder.customizers
(Iterable<? extends SimpleAsyncTaskSchedulerCustomizer> customizers) Set thethreadPoolTaskSchedulerCustomizers
that should be applied to theSimpleAsyncTaskScheduler
.customizers
(SimpleAsyncTaskSchedulerCustomizer... customizers) Set thethreadPoolTaskSchedulerCustomizers
that should be applied to theSimpleAsyncTaskScheduler
.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
-
SimpleAsyncTaskSchedulerBuilder
public SimpleAsyncTaskSchedulerBuilder()
-
-
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
-
concurrencyLimit
Set the concurrency limit.- Parameters:
concurrencyLimit
- the concurrency limit- Returns:
- a new builder instance
-
virtualThreads
Set whether to use virtual threads.- Parameters:
virtualThreads
- whether to use virtual threads- Returns:
- a new builder instance
-
customizers
public SimpleAsyncTaskSchedulerBuilder customizers(SimpleAsyncTaskSchedulerCustomizer... customizers) Set thethreadPoolTaskSchedulerCustomizers
that should be applied to theSimpleAsyncTaskScheduler
. 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 SimpleAsyncTaskSchedulerBuilder customizers(Iterable<? extends SimpleAsyncTaskSchedulerCustomizer> customizers) Set thethreadPoolTaskSchedulerCustomizers
that should be applied to theSimpleAsyncTaskScheduler
. 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 SimpleAsyncTaskSchedulerBuilder additionalCustomizers(SimpleAsyncTaskSchedulerCustomizer... customizers) AddthreadPoolTaskSchedulerCustomizers
that should be applied to theSimpleAsyncTaskScheduler
. 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 SimpleAsyncTaskSchedulerBuilder additionalCustomizers(Iterable<? extends SimpleAsyncTaskSchedulerCustomizer> customizers) AddthreadPoolTaskSchedulerCustomizers
that should be applied to theSimpleAsyncTaskScheduler
. 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 newSimpleAsyncTaskScheduler
instance and configure it using this builder.- Returns:
- a configured
SimpleAsyncTaskScheduler
instance. - See Also:
-
configure
Configure the providedSimpleAsyncTaskScheduler
instance using this builder.- Type Parameters:
T
- the type of task scheduler- Parameters:
taskScheduler
- theSimpleAsyncTaskScheduler
to configure- Returns:
- the task scheduler instance
- See Also:
-