First of all, if you use Java 5 and higher (required for Java Futures, etc.), then the default TaskExecutor should be ThreadPoolTaskExecutor, which corresponds to the output of the debug trace. This is a thread manager that actually runs your test code.
Simple AsyncTaskExecutor most likely starts as part of the Spring task runtime, possibly from a different annotation in your test context file. A Spring container can run four instances of the SimpleAsyncTaskExecutor class. According to Spring documentation, this version of TaskExecutor never repeats using threads to satisfy new requests (it will start a new thread):
SimpleAsyncTaskExecutor
This implementation does not use many threads, but launches a new thread for each call. However, it maintains a concurrency limit that blocks any that exceed the limit until the slot is freed. If you are looking for true unification, keep scrolling down the page.
Link: http://docs.spring.io/spring/docs/3.1.x/spring-framework-reference/html/scheduling.html#scheduling-task-executor
Therefore, this may be the result of the interaction between the test context and the Spring container.
I believe that in this scenario there is one thread that runs your test code, and this is what you expect based on a single request. Spring TaskExecutor implementations use the ConcurrencyThrottleSupport helper class, which must throttle (limit) the number of concurrent threads on execution. In your case, it should be 2, as indicated by the pool size property. However, to run this test, you never need to allocate an extra thread, and the trace output is consistent with this.
source share