Announcement Announcement Module
Collapse
No announcement yet.
Max pool size in ThreadPoolTaskExecutor Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • 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
    I have the same issue here. Does anybody know what is wrong?


    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!

    Comment


    • #3
      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, 12:07 PM.

      Comment

      Working...
      X