Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Spring ThreadPoolTaskExecutor never grows beyond corePoolSize

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?

like image 298
Denis Kulagin Avatar asked Dec 25 '22 06:12

Denis Kulagin


1 Answers

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!

like image 110
Denis Kulagin Avatar answered Dec 28 '22 05:12

Denis Kulagin