Results 1 to 3 of 3

Thread: Max pool size in ThreadPoolTaskExecutor

Hybrid View

  1. #1
    Join Date
    Aug 2010
    Location
    London
    Posts
    1

    Unhappy 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" />
    </bean>

    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?

    Thanks!

  2. #2
    Join Date
    Oct 2005
    Posts
    14

    Default

    I have the same issue here. Does anybody know what is wrong?


    Quote Originally Posted by ragstorooks View Post
    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" />
    </bean>

    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?

    Thanks!

  3. #3
    Join Date
    Oct 2005
    Posts
    14

    Default

    Quote Originally Posted by hairinwind View Post
    I have the same issue here. Does anybody know what is wrong?
    Somebody reported a bug here http://bugs.sun.com/bugdatabase/view...bug_id=6756747

    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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •