类 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.
- 从以下版本开始:
- 3.2.0
- 作者:
- Stephane Nicoll, Filip Hrisafov, Moritz Halbritter, Yanming Zhou
-
构造器概要
构造器 -
方法概要
修饰符和类型方法说明additionalCustomizers(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.rejectTasksWhenLimitReached(boolean rejectTasksWhenLimitReached) Set whether to reject tasks when the concurrency limit has been reached.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.
-
构造器详细资料
-
SimpleAsyncTaskExecutorBuilder
public SimpleAsyncTaskExecutorBuilder()
-
-
方法详细资料
-
threadNamePrefix
Set the prefix to use for the names of newly created threads.- 参数:
threadNamePrefix- the thread name prefix to set- 返回:
- a new builder instance
-
virtualThreads
Set whether to use virtual threads.- 参数:
virtualThreads- whether to use virtual threads- 返回:
- a new builder instance
-
rejectTasksWhenLimitReached
public 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.- 参数:
rejectTasksWhenLimitReached- whether to reject tasks when the concurrency limit has been reached- 返回:
- a new builder instance
- 从以下版本开始:
- 3.5.0
-
concurrencyLimit
Set the concurrency limit.- 参数:
concurrencyLimit- the concurrency limit- 返回:
- a new builder instance
-
taskDecorator
Set theTaskDecoratorto use ornullto not use any.- 参数:
taskDecorator- the task decorator to use- 返回:
- a new builder instance
-
taskTerminationTimeout
Set the task termination timeout.- 参数:
taskTerminationTimeout- the task termination timeout- 返回:
- a new builder instance
- 从以下版本开始:
- 3.2.1
-
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.- 参数:
customizers- the customizers to set- 返回:
- a new builder instance
- 另请参阅:
-
customizers
public 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.- 参数:
customizers- the customizers to set- 返回:
- a new builder instance
- 另请参阅:
-
additionalCustomizers
public 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.- 参数:
customizers- the customizers to add- 返回:
- a new builder instance
- 另请参阅:
-
additionalCustomizers
public 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.- 参数:
customizers- the customizers to add- 返回:
- a new builder instance
- 另请参阅:
-
build
Build a newSimpleAsyncTaskExecutorinstance and configure it using this builder.- 返回:
- a configured
SimpleAsyncTaskExecutorinstance. - 另请参阅:
-
build
Build a newSimpleAsyncTaskExecutorinstance of the specified type and configure it using this builder.- 类型参数:
T- the type of task executor- 参数:
taskExecutorClass- the template type to create- 返回:
- a configured
SimpleAsyncTaskExecutorinstance. - 另请参阅:
-
configure
Configure the providedSimpleAsyncTaskExecutorinstance using this builder.- 类型参数:
T- the type of task executor- 参数:
taskExecutor- theSimpleAsyncTaskExecutorto configure- 返回:
- the task executor instance
- 另请参阅:
-