2014-07-15 77 views
3

我已經配置春天ThreadPoolTask​​Executor類,銘記16個線程至少和256個需要爲基礎計算:春ThreadPoolTask​​Executor類從不增長超過corePoolSize

<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

也許從來沒有必要超過'corePoolSize'線程。 – isnot2bad

+0

任務在線程池中等待的時間長達500毫秒......感覺有一個很好的理由來增長。 –

+0

此外,如果我將* corePoolSize *設置爲1,問題仍然存在。 –

回答

5

明白了:

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

所以解決的辦法就是收縮隊列!

相關問題