title: Spring SimpleAsyncTaskExecutor and ThreadPoolTaskExecutor with @Async annotation
body: <p>I have the following configutation:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xmlns:context="http://www.springframework.org/schema/context"
      xmlns:task="http://www.springframework.org/schema/task"
      xsi:schemaLocation="http://www.springframework.org/schema/beans
          http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
          http://www.springframework.org/schema/context
          http://www.springframework.org/schema/context/spring-context-3.0.xsd
          http://www.springframework.org/schema/task http://www.springframework.org/schema/task/spring-task-3.0.xsd"&gt;
  
      &lt;context:component-scan base-package="com.abc" /&gt;
      &lt;task:annotation-driven executor="executor"/&gt;
      &lt;task:executor id="executor" pool-size="2"/&gt;
  
  &lt;/beans&gt;
  </code></pre>
  
  <p>Then the following class</p>
  
  <pre><code>public class SomeClassImpl implements SomeClass {
  
     @Async
     @Override // overridden from the interface
     public void doSomething(){
        System.out.println("doing something async");
     }
  }
  </code></pre>
  
  <p>A test:</p>
  
  <pre><code>@ContextConfiguration("classpath:test-config.xml") // with the xml config above
  @RunWith(value = SpringJUnit4ClassRunner.class)
  public class SomeClassTest {
  
     @Autowired
     private SomeClass someClass;
  
     @Test
     public void testSomething() throws Exception {
  
        System.out.println("Calling doSomething");
        someClass.doSomething();
        Thread.sleep(5000);
     }
  }
  </code></pre>
  
  <p>When I ran the test, everything worked as expected. But then I attached the debugger to step through what is actually happening when someClass.doSomething() is called and i noticed the following:</p>
  
  <p><img src="https://i.stack.imgur.com/efQTC.gif" alt="enter image description here"></p>
  
  <p>Why is it that 4 threads are being created by a SimpleAsyncTaskExecutor? I know that if I remove the executor property from the task:annotation-driven xml element, the AsyncExecutionInterceptor will use the SimpleAsyncTaskExecutor. But since I have declared a task executor and referenced it from the annotation-driven element, why is a SimpleAsyncTaskExecutor being created? </p>