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
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionadditionalCustomizers
(Iterable<? extends SimpleAsyncTaskSchedulerCustomizer> customizers) Addcustomizers
that should be applied to theSimpleAsyncTaskScheduler
.additionalCustomizers
(SimpleAsyncTaskSchedulerCustomizer... customizers) Addcustomizers
that should be applied to theSimpleAsyncTaskScheduler
.org.springframework.scheduling.concurrent.SimpleAsyncTaskScheduler
build()
Build a newSimpleAsyncTaskScheduler
instance and configure it using this builder.concurrencyLimit
(Integer concurrencyLimit) Set the concurrency limit.<T extends org.springframework.scheduling.concurrent.SimpleAsyncTaskScheduler>
Tconfigure
(T taskScheduler) Configure the providedSimpleAsyncTaskScheduler
instance using this builder.customizers
(Iterable<? extends SimpleAsyncTaskSchedulerCustomizer> customizers) Set thecustomizers
that should be applied to theSimpleAsyncTaskScheduler
.customizers
(SimpleAsyncTaskSchedulerCustomizer... customizers) Set thecustomizers
that should be applied to theSimpleAsyncTaskScheduler
.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
-
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
-
taskTerminationTimeout
Set the task termination timeout.- Parameters:
taskTerminationTimeout
- the task termination timeout- Returns:
- a new builder instance
- Since:
- 3.2.1
-
customizers
public SimpleAsyncTaskSchedulerBuilder customizers(SimpleAsyncTaskSchedulerCustomizer... customizers) Set thecustomizers
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 thecustomizers
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) Addcustomizers
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) Addcustomizers
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
public org.springframework.scheduling.concurrent.SimpleAsyncTaskScheduler build()Build a newSimpleAsyncTaskScheduler
instance and configure it using this builder.- Returns:
- a configured
SimpleAsyncTaskScheduler
instance. - See Also:
-
configure
public <T extends org.springframework.scheduling.concurrent.SimpleAsyncTaskScheduler> T configure(T taskScheduler) 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:
-