title: Spring Async get current Executor
body: <p>I am using Spring <code>Async</code> by implementing <a href="https://docs.spring.io/spring-framework/docs/current/javadoc-api/org/springframework/scheduling/annotation/AsyncConfigurer.html" rel="nofollow noreferrer"><code>AsyncConfigurer</code></a> and overriding the <a href="https://docs.spring.io/spring-framework/docs/current/javadoc-api/org/springframework/scheduling/annotation/AsyncConfigurer.html#getAsyncExecutor--" rel="nofollow noreferrer"><code>getAsyncExecutor</code></a> to define my <code>Executor</code>.
  Now I would like to expose an endpoint, to return the current queue size, number of threads ...etc, of the Executor that is used by Async.
  But I could not find a way to find or autowire the current executor that is used by Async.
  I was thinking I can define a bean, that will be both used by the <code>getAsyncExecutor</code> method, and my reporting service.
  But I was wondering if there is an easier/more appropriate way I can interact with async to get the current <code>Executor</code>.</p>
  <p>My current config:</p>
  <pre><code>@Configuration
  @EnableAsync
  public class AsyncConfiguration implements AsyncConfigurer {
  
      @Override
      public Executor getAsyncExecutor() {
          final ThreadPoolTaskExecutor threadPoolTaskExecutor = new ThreadPoolTaskExecutor();
  
          threadPoolTaskExecutor.setThreadNamePrefix(&quot;async-thread-&quot;);
          threadPoolTaskExecutor.setCorePoolSize(2);
          threadPoolTaskExecutor.setMaxPoolSize(2);
          threadPoolTaskExecutor.setQueueCapacity(100);
  
          threadPoolTaskExecutor.initialize();
  
          return threadPoolTaskExecutor;
      }
  }
  </code></pre>