title: Java: SingleThreadScheduledExecutor & java.util.concurrent.RejectedExecutionException
body: <p>I am having this problem, I have </p>
  
  <pre><code>private ScheduledExecutorService executor =  
       Executors.newSingleThreadScheduledExecutor(); 
  </code></pre>
  
  <p>and task which is created every 50 millliseconds:  </p>
  
  <pre><code>executor.scheduleAtFixedRate(myTask, 0, 50, TimeUnit.MILLISECONDS);
  </code></pre>
  
  <p><code>myTask</code> sometimes take a while to complete (like 2-3 seconds or so), but newSingleThreadScheduledExecutor guarantees that next scheduled myTask will wait until the current one completes.</p>
  
  <p>However, I get this error from time to time:</p>
  
  <p>execute: <code>java.util.concurrent.RejectedExecutionException</code></p>
  
  <p>What should I do? Thanks</p>