title: Running each Spring Scheduler in its own thread
body: <p>I have multiple components with <code>@Scheduled</code> annotations, and I see that Spring only starts one at a time, even if they are scheduled to run on the same time.</p>
  
  <p>My use case is as follows. I want each @Scheduled annotation to run in its own thread, but only once for each thread.</p>
  
  <p>Given this <strong>pseudo code</strong> with two schedulers:</p>
  
  <pre><code>@Scheduled(cron = "0 * * * * *") //run every minute
  public void methodA() {
     log.info("Running method A");
     executeLongRunningJob("Finished method A");
  }
  
  @Scheduled(cron = "0 * * * * *") //run every minute
  public void methodB() {
     log.info("Running method B");
     executeLongRunningJob("Finished method B");       
  }
  
  private void executeLongRunningJob(String msg) {
      Thread.sleep(70 seconds);
      System.out.println(msg);
  }
  </code></pre>
  
  <p><strong>Note that the task takes longer time than the scheduler is scheduled to run. This is crucial. I don't want the scheduler to start again before its finished running.</strong></p>
  
  <p>Running this code out of the box gives me this output:</p>
  
  <pre><code>Running method A
  Finished method A
  Running method B
  Finished method B
  Running method A
  Finished method A
  Running method B
  Finished method B
  ... and so on
  </code></pre>
  
  <p>So obviously its running both schedulers in a single thread.</p>
  
  <hr>
  
  <p>When I put <code>@Async</code> on my expensive method, then I almost get the correct behavior, except the expensive method is not finished before a new scheduler is started.</p>
  
  <pre><code>Running method A
  Running method B
  Running method A
  Running method B
  Finished method A
  Finished method B
  ... and so on
  </code></pre>
  
  <hr>
  
  <p>What I would like is this output:</p>
  
  <pre><code>Running method A  
  Running method B
  Finished method A 
  Finished method B 
  Running method A 
  Running method B 
  Finished method A 
  Finished method B
  ... and so on
  </code></pre>
  
  <p>How can I accomplish this?
  I want each Scheduler to run concurrently, but wait until it is finished before allowed to run again.
  Remember I have more than two Schedulers running in same and sometimes different times.</p>