Aug 4th, 2010, 08:55 AM
Max pool size in ThreadPoolTaskExecutor
I'm defining my thread pool with the following lines in my application context:
<bean id="executor" class="org.springframework.scheduling.concurrent.T hreadPoolTaskExecutor">
<property name="corePoolSize" value="5" />
<property name="maxPoolSize" value="200" />
But when I check the usage of the thread pool during execution using executor.getActiveCount(), I only see the active count going up to core pool size. It never goes beyond that even though there are more threads queued up. I'm sure I'm missing something - what is it?
Nov 9th, 2012, 06:28 PM
I have the same issue here. Does anybody know what is wrong?
Originally Posted by ragstorooks
Nov 12th, 2012, 11:54 AM
Somebody reported a bug here http://bugs.sun.com/bugdatabase/view...bug_id=6756747
Originally Posted by hairinwind
Here is the problem.
ThreadPoolExecutor with corePoolSize value lower than maxPoolSize will never try to add new threads beyond corePoolSize when tasks are submitted using unbounded queue.
Here is the answer from SUN
That is exactly how it is supposed to behave. First the threads grow to coreSize, then the queue is used, then *if* the queue fills up then the number of threads expands from coreSize to maxSize. Hence if you use an unbounded queue the last part never happens. This is all described in the documentation.
If you want an unbounded queue but more threads then increase the core size. Otherwise consider whether a bounded queue is more suitable to your needs.
Interesting... I hope the queue starts working when the thread pool reaches its maxPoolSize. But sun's design is that the queue starts working when the thread pool reaches its corePoolSize and then push new tasks to the queue. It won't increase the pool size to the maxPoolSize until the queue is full.
Last edited by hairinwind; Nov 12th, 2012 at 12:07 PM.
Tags for this Thread