gpt4 book ai didi

java - Spring ThreadPoolTask​​Executor 永远不会超出 corePoolSize

转载 作者:搜寻专家 更新时间:2023-11-01 01:34:21 25 4
gpt4 key购买 nike

我已经配置了 Spring ThreadPoolTask​​Executor,考虑到至少有 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

为什么会这样?我做错了什么?

最佳答案

明白了:

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

所以解决办法就是缩小队列!

关于java - Spring ThreadPoolTask​​Executor 永远不会超出 corePoolSize,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24759170/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com