Spring ThreadPoolTaskExecutor never grows beyond corePoolSize

浪子不回头ぞ 提交于 2020-01-14 13:53:07

问题


I have configured Spring ThreadPoolTaskExecutor, having in mind 16 threads at least and up to 256 on the need-basis:

<bean id="taskExecutor" class="org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor">
    <property name="corePoolSize" value="16"/>
    <property name="maxPoolSize" value="256"/>
    <property name="queueCapacity" value="256"/>
</bean>

But as I can see from logs, thread pool size never exceeds corePoolSize:

Thread pool size: 16/256, active count: 16

Why is that so? What have I done wrong?


回答1:


Got it:

If there are more than corePoolSize but less
than maximumPoolSize threads running,
a new thread will be created only if the queue is full.

So the solution is to shrink the queue!



来源:https://stackoverflow.com/questions/24759170/spring-threadpooltaskexecutor-never-grows-beyond-corepoolsize

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!