我已经配置了Spring ThreadPoolTaskExecutor,根据需要考虑至少16个线程,最多256个:
<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>
但正如我从日志中看到的那样,线程池大小永远不会超过 corePoolSize :
Thread pool size: 16/256, active count: 16
为什么会这样?我做错了什么?
答案 0 :(得分:9)
知道了:
If there are more than corePoolSize but less
than maximumPoolSize threads running,
a new thread will be created only if the queue is full.
所以解决方案是缩小队列!