title: Problems with pool size of Spring's ThreadPoolTaskExecutor
body: <p>I'm doing some load tests agains my Spring application and now I'm a little bit confused about the configuration of the <code>ThreadPoolTaskExecutor</code>.</p>
  
  <p>The documentation of the internally used <code>ThreadPoolExecutor</code> describes the <code>corePoolSize</code> as "the number of threads to keep in the pool, even if they are idle, [...]" and <code>maximumPoolSize</code> as "the maximum number of threads to allow in the pool".</p>
  
  <p>That obviously means that the <code>maximumPoolSize</code> limits the number of thread in the pool. But instead the limit seems the be set by the <code>corePoolSize</code>. Actually I configured just the <code>corePoolSize</code> with <code>100</code> an let the <code>maximumPoolSize</code> unconfigured (that means the default value is used: <code>Integer.MAX_VALUE</code> = <code>2147483647</code>).</p>
  
  <p>When I run the load test I can see (by reviewing the logs), that the executed worker thread are numbered from <code>worker-1</code> to <code>worker-100</code>. So in this case the thread pool size is limited by <code>corePoolSize</code>. Even if I set <code>maximumPoolSize</code> to <code>200</code> or <code>300</code>, the result is exactly the same.</p>
  
  <p>Why the value of <code>maximumPoolSize</code> has no affect in my case?</p>
  
  <pre><code>@Bean
  public TaskExecutor taskExecutor() {
      ThreadPoolTaskExecutor taskExecutor = new ThreadPoolTaskExecutor();
      taskExecutor.setCorePoolSize(100);
      taskExecutor.setThreadNamePrefix("worker-");
      return taskExecutor;
  }
  </code></pre>
  
  <p><strong>SOLUTION</strong></p>
  
  <p>I've found the solution in the documentation: "<em>If there are more than corePoolSize but less than maximumPoolSize threads running, a new thread will be created only if the queue is full</em>". The default queue size is <code>Integer.MAX_VALUE</code>. If I limit the queue, everything works fine.</p>