title: Should I have a singleton ThreadPoolTaskExecutor to be shared different services?
body: <p>I have declared ThreadPoolTaskExecutor as a @Bean as per my application context as :</p>
  
  <pre><code>@Configuration
  @ConfigurationProperties(prefix = "application")
  @EnableCaching
  public class ApplicationConfig {
      private static final int POOL_SIZE = 2;
  
      @Bean
      public ThreadPoolTaskExecutor taskExecutor() {
          ThreadPoolTaskExecutor pool = new ThreadPoolTaskExecutor();
          pool.setCorePoolSize(POOL_SIZE);
  
          return pool;
      }
  }
  </code></pre>
  
  <p>I have 2 different services that need get wired an instance of ThreadPoolTaskExecutor. Each service will submit a Runnable that will do some service-specific job. </p>
  
  <p>For example, these are the 2 services:</p>
  
  <pre><code>@Service
  public class TerminatedContractsService {
      @Autowired
      private ThreadPoolTaskExecutor taskExec;
  
      public void notifyTerminatedContracts(Date d) {
          // do some contract specific work
          taskExec.submit(() -&gt; System.out.println("emailing terminated contracts...")); 
      }
  }
  
  
  @Service
  public class SalaryCalculationService {
      @Autowired
      private ThreadPoolTaskExecutor taskExec;
  
      public void calculateSalary(Date d) {
          // do some salary related work
          taskExec.submit(() -&gt; System.out.println("calculating salaries...")); 
      }
  }
  </code></pre>
  
  <p>Is should be safe to share the same ThreadPoolTaskExecutor instance (since its singleton) for both services right? </p>
  
  <p>Do you foresee any issues with this and if I should prototype instead?</p>