I have a thread-pool initialized as a @Bean for purpose of dedicated execution of a particular @Async method
class MyConfig {
    @Bean(name="myPool")
    public static TaskExecutor getExecutor(){
        ThreadPooltaskExecutor exec = new ThreadPoolTaskExecutor();
        exec.setCorePoolSize(1);
        exec.setMaxPoolSize(1);
        exec.setThreadNamePrefix("my-thread");
        exec.initialize();
        return exec;
    }
}
Above thread-pool as a bean is used in Async method call like below:
public class MyHandler {
    ...
    @Async("myPool")
    public void handle(){
        ...
        logger.INFO("do my thing");
        ...
    }
    ...
}
There are other classes also which are using default Spring @Async pool, like:
public class OtherScheduledTask {
    ...
    @Async
    public void doThat() {
        logger.INFO("doing that thing");
    }
    ...
}
On running application I can see the following in logs:
[pool-1-thread-1] [] c.c.a.m.p.e.c.OtherScheduledTask - do my thing
[myPool] [] c.c.a.m.p.e.c.MyHandler - doing that thing
....
I see above log snippets randomly getting printed and async methods are getting executed by default thread-pool and custom thread pool intermittently
I do have scenarios where I am calling @Async methods from non-async methods
However, I have used my custom thread-pool strictly only with one @Async method handle() in MyHandler and no-where else
Why spring is mixing thread-pools (both custom and default) for executing @async methods?
What is the use of passing bean name in @Async method annotation?
How I can have dedicated thread-pool with one particular async method, so that when it is not executing, let the thread-pool be idle and not getting used for other async methods which should be executed only by default spring thread pool
Details about my environment: Spring boot version 1.4.2 RELEASE JDK 1.8.0
 
     
    