title: spring boot TaskExecutor thread pool size
body: <p>I am use spring boot 2.0.2, and use Async to execute tasks. </p>
  
  <p>I register a TaskExecutor to control thread pool size, like below:</p>
  
  <pre><code>public class ThreadConfig {
  @Bean
  public TaskExecutor threadPoolTaskExecutor() {
  
      ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
  
      executor.setCorePoolSize(2);
      executor.setMaxPoolSize(3);
      executor.setQueueCapacity(3);
      executor.setThreadNamePrefix("anniversary");
  
      executor.initialize();
      System.out.println("******* name "  + executor.getThreadNamePrefix());
      System.out.println("********** core pool size " + executor.getCorePoolSize());
  
      return executor;
  }
  
  }
  </code></pre>
  
  <p>But during running, there are more than 20 threads are created, </p>
  
  <pre><code>*********Thread[SimpleAsyncTaskExecutor-1,5,com.abc.team1.project1.anniversary.AnniversaryApplication]*********
  **********Thread[SimpleAsyncTaskExecutor-2,5,com.abc.team1.project1.anniversary.AnniversaryApplication]*********
  **********Thread[SimpleAsyncTaskExecutor-3,5,com.abc.team1.project1.anniversary.AnniversaryApplication]*********
  **********Thread[SimpleAsyncTaskExecutor-4,5,com.abc.team1.project1.anniversary.AnniversaryApplication]*********
  **********Thread[SimpleAsyncTaskExecutor-5,5,com.abc.team1.project1.anniversary.AnniversaryApplication]*********
  **********Thread[SimpleAsyncTaskExecutor-6,5,com.abc.team1.project1.anniversary.AnniversaryApplication]*********
  **********Thread[SimpleAsyncTaskExecutor-7,5,com.abc.team1.project1.anniversary.AnniversaryApplication]*********
  **********Thread[SimpleAsyncTaskExecutor-8,5,com.abc.team1.project1.anniversary.AnniversaryApplication]*********
  **********Thread[SimpleAsyncTaskExecutor-9,5,com.abc.team1.project1.anniversary.AnniversaryApplication]*********
  **********Thread[SimpleAsyncTaskExecutor-10,5,com.abc.team1.project1.anniversary.AnniversaryApplication]*********
  **********Thread[SimpleAsyncTaskExecutor-11,5,com.abc.team1.project1.anniversary.AnniversaryApplication]*********
  **********Thread[SimpleAsyncTaskExecutor-12,5,com.abc.team1.project1.anniversary.AnniversaryApplication]*********
  **********Thread[SimpleAsyncTaskExecutor-13,5,com.abc.team1.project1.anniversary.AnniversaryApplication]*********
  **********Thread[SimpleAsyncTaskExecutor-14,5,com.abc.team1.project1.anniversary.AnniversaryApplication]*********
  </code></pre>