类 TaskExecutorRegistration
- java.lang.Object
- org.springframework.messaging.simp.config.TaskExecutorRegistration
public class TaskExecutorRegistration extends Object
A registration class for customizing the properties ofThreadPoolTaskExecutor
.- 从以下版本开始:
- 4.0
- 作者:
- Rossen Stoyanchev, Juergen Hoeller
构造器概要
构造器 构造器 说明 TaskExecutorRegistration()
Create a newTaskExecutorRegistration
for a defaultThreadPoolTaskExecutor
.TaskExecutorRegistration(ThreadPoolTaskExecutor taskExecutor)
Create a newTaskExecutorRegistration
for a givenThreadPoolTaskExecutor
.
方法概要
所有方法 实例方法 具体方法 修饰符和类型 方法 说明 TaskExecutorRegistration
corePoolSize(int corePoolSize)
Set the core pool size of the ThreadPoolExecutor.protected ThreadPoolTaskExecutor
getTaskExecutor()
TaskExecutorRegistration
keepAliveSeconds(int keepAliveSeconds)
Set the time limit for which threads may remain idle before being terminated.TaskExecutorRegistration
maxPoolSize(int maxPoolSize)
Set the max pool size of the ThreadPoolExecutor.TaskExecutorRegistration
queueCapacity(int queueCapacity)
Set the queue capacity for the ThreadPoolExecutor.
构造器详细资料
TaskExecutorRegistration
public TaskExecutorRegistration()
Create a newTaskExecutorRegistration
for a defaultThreadPoolTaskExecutor
.
TaskExecutorRegistration
public TaskExecutorRegistration(ThreadPoolTaskExecutor taskExecutor)
Create a newTaskExecutorRegistration
for a givenThreadPoolTaskExecutor
.- 参数:
taskExecutor
- the executor to use
方法详细资料
corePoolSize
public TaskExecutorRegistration corePoolSize(int corePoolSize)
Set the core pool size of the ThreadPoolExecutor.NOTE: The core pool size is effectively the max pool size when an unbounded
queueCapacity
is configured (the default). This is essentially the "Unbounded queues" strategy as explained inThreadPoolExecutor
. When this strategy is used, themaxPoolSize
is ignored.By default this is set to twice the value of
Runtime.availableProcessors()
. In an application where tasks do not block frequently, the number should be closer to or equal to the number of available CPUs/cores.
maxPoolSize
public TaskExecutorRegistration maxPoolSize(int maxPoolSize)
Set the max pool size of the ThreadPoolExecutor.NOTE: When an unbounded
queueCapacity
is configured (the default), the max pool size is effectively ignored. See the "Unbounded queues" strategy inThreadPoolExecutor
for more details.By default this is set to
Integer.MAX_VALUE
.
keepAliveSeconds
public TaskExecutorRegistration keepAliveSeconds(int keepAliveSeconds)
Set the time limit for which threads may remain idle before being terminated. If there are more than the core number of threads currently in the pool, after waiting this amount of time without processing a task, excess threads will be terminated. This overrides any value set in the constructor.By default this is set to 60.
queueCapacity
public TaskExecutorRegistration queueCapacity(int queueCapacity)
Set the queue capacity for the ThreadPoolExecutor.NOTE: when an unbounded
queueCapacity
is configured (the default), the core pool size is effectively the max pool size. This is essentially the "Unbounded queues" strategy as explained inThreadPoolExecutor
. When this strategy is used, themaxPoolSize
is ignored.By default this is set to
Integer.MAX_VALUE
.
getTaskExecutor
protected ThreadPoolTaskExecutor getTaskExecutor()