title: Spring Scheduler synchronized method starvation
body: <p>Assume I have a scheduler</p>
  
  <pre><code>@Component
  public class Scheduler{
  
      private static int counter = 0;
  
      private synchronized void countIt(){
          counter++;
      }
  
      @Scheduled(fixedDelay = 3000)
      public void job1(){
          countIt();
      }
  
      @Scheduled(fixedDelay = 6000)
      public void job2(){
          countIt();
      }
  }
  </code></pre>
  
  <p>Different task trigger in different case will call countIt.</p>
  
  <p>When two or more job call countIt simultaneous, it will cause starvation.</p>
  
  <p>Could any one tell me if there is a way to avoid this situation?</p>