类 ThreadPoolTaskSchedulerBuilder
java.lang.Object
org.springframework.boot.task.ThreadPoolTaskSchedulerBuilder
Builder that can be used to configure and create a
ThreadPoolTaskScheduler.
Provides convenience methods to set common ThreadPoolTaskScheduler settings.
For advanced configuration, consider using ThreadPoolTaskSchedulerCustomizer.
In a typical auto-configured Spring Boot application this builder is available as a
bean and can be injected whenever a ThreadPoolTaskScheduler is needed.
- 从以下版本开始:
- 3.2.0
- 作者:
- Stephane Nicoll
-
构造器概要
构造器构造器说明ThreadPoolTaskSchedulerBuilder(Integer poolSize, Boolean awaitTermination, Duration awaitTerminationPeriod, String threadNamePrefix, Set<ThreadPoolTaskSchedulerCustomizer> taskSchedulerCustomizers) 已过时, 待删除: 此 API 元素将从以后的版本中删除。since 3.5.0 for removal in 4.0.0 in favor of the default constructor -
方法概要
修饰符和类型方法说明additionalCustomizers(Iterable<? extends ThreadPoolTaskSchedulerCustomizer> customizers) AddthreadPoolTaskSchedulerCustomizersthat should be applied to theThreadPoolTaskScheduler.additionalCustomizers(ThreadPoolTaskSchedulerCustomizer... customizers) AddthreadPoolTaskSchedulerCustomizersthat should be applied to theThreadPoolTaskScheduler.awaitTermination(boolean awaitTermination) Set whether the executor should wait for scheduled tasks to complete on shutdown, not interrupting running tasks and executing all tasks in the queue.awaitTerminationPeriod(Duration awaitTerminationPeriod) Set the maximum time the executor is supposed to block on shutdown.build()Build a newThreadPoolTaskSchedulerinstance and configure it using this builder.<T extends ThreadPoolTaskScheduler>
Tconfigure(T taskScheduler) Configure the providedThreadPoolTaskSchedulerinstance using this builder.customizers(Iterable<? extends ThreadPoolTaskSchedulerCustomizer> customizers) Set thethreadPoolTaskSchedulerCustomizersthat should be applied to theThreadPoolTaskScheduler.customizers(ThreadPoolTaskSchedulerCustomizer... customizers) Set thethreadPoolTaskSchedulerCustomizersthat should be applied to theThreadPoolTaskScheduler.poolSize(int poolSize) Set the maximum allowed number of threads.taskDecorator(TaskDecorator taskDecorator) Set theTaskDecoratorto be applied to theThreadPoolTaskScheduler.threadNamePrefix(String threadNamePrefix) Set the prefix to use for the names of newly created threads.
-
构造器详细资料
-
ThreadPoolTaskSchedulerBuilder
public ThreadPoolTaskSchedulerBuilder() -
ThreadPoolTaskSchedulerBuilder
@Deprecated(since="3.5.0", forRemoval=true) public ThreadPoolTaskSchedulerBuilder(Integer poolSize, Boolean awaitTermination, Duration awaitTerminationPeriod, String threadNamePrefix, Set<ThreadPoolTaskSchedulerCustomizer> taskSchedulerCustomizers) 已过时, 待删除: 此 API 元素将从以后的版本中删除。since 3.5.0 for removal in 4.0.0 in favor of the default constructorConstructs a newThreadPoolTaskSchedulerBuilderinstance with the specified configuration.- 参数:
poolSize- the maximum allowed number of threadsawaitTermination- whether the executor should wait for scheduled tasks to complete on shutdownawaitTerminationPeriod- the maximum time the executor is supposed to block on shutdownthreadNamePrefix- the prefix to use for the names of newly created threadstaskSchedulerCustomizers- the customizers to apply to theThreadPoolTaskScheduler
-
-
方法详细资料
-
poolSize
Set the maximum allowed number of threads.- 参数:
poolSize- the pool size to set- 返回:
- a new builder instance
-
awaitTermination
Set whether the executor should wait for scheduled tasks to complete on shutdown, not interrupting running tasks and executing all tasks in the queue.- 参数:
awaitTermination- whether the executor needs to wait for the tasks to complete on shutdown- 返回:
- a new builder instance
- 另请参阅:
-
awaitTerminationPeriod
Set the maximum time the executor is supposed to block on shutdown. When set, the executor blocks on shutdown in order to wait for remaining tasks to complete their execution before the rest of the container continues to shut down. This is particularly useful if your remaining tasks are likely to need access to other resources that are also managed by the container.- 参数:
awaitTerminationPeriod- the await termination period to set- 返回:
- a new builder instance
-
threadNamePrefix
Set the prefix to use for the names of newly created threads.- 参数:
threadNamePrefix- the thread name prefix to set- 返回:
- a new builder instance
-
taskDecorator
Set theTaskDecoratorto be applied to theThreadPoolTaskScheduler.- 参数:
taskDecorator- the task decorator to set- 返回:
- a new builder instance
- 从以下版本开始:
- 3.5.0
-
customizers
Set thethreadPoolTaskSchedulerCustomizersthat should be applied to theThreadPoolTaskScheduler. 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.- 参数:
customizers- the customizers to set- 返回:
- a new builder instance
- 另请参阅:
-
customizers
public ThreadPoolTaskSchedulerBuilder customizers(Iterable<? extends ThreadPoolTaskSchedulerCustomizer> customizers) Set thethreadPoolTaskSchedulerCustomizersthat should be applied to theThreadPoolTaskScheduler. 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.- 参数:
customizers- the customizers to set- 返回:
- a new builder instance
- 另请参阅:
-
additionalCustomizers
public ThreadPoolTaskSchedulerBuilder additionalCustomizers(ThreadPoolTaskSchedulerCustomizer... customizers) AddthreadPoolTaskSchedulerCustomizersthat should be applied to theThreadPoolTaskScheduler. Customizers are applied in the order that they were added after builder configuration has been applied.- 参数:
customizers- the customizers to add- 返回:
- a new builder instance
- 另请参阅:
-
additionalCustomizers
public ThreadPoolTaskSchedulerBuilder additionalCustomizers(Iterable<? extends ThreadPoolTaskSchedulerCustomizer> customizers) AddthreadPoolTaskSchedulerCustomizersthat should be applied to theThreadPoolTaskScheduler. Customizers are applied in the order that they were added after builder configuration has been applied.- 参数:
customizers- the customizers to add- 返回:
- a new builder instance
- 另请参阅:
-
build
Build a newThreadPoolTaskSchedulerinstance and configure it using this builder.- 返回:
- a configured
ThreadPoolTaskSchedulerinstance. - 另请参阅:
-
configure
Configure the providedThreadPoolTaskSchedulerinstance using this builder.- 类型参数:
T- the type of task scheduler- 参数:
taskScheduler- theThreadPoolTaskSchedulerto configure- 返回:
- the task scheduler instance
- 另请参阅:
-