title: how to check if a scheduled thread has finished the task?
body: <p>I have a task that executes every 20 seconds . But the problem is that the task can make a delay so that will cause an interruption.</p>
  
  <pre><code>package client;
  
  import java.util.concurrent.ScheduledThreadPoolExecutor;
  import static java.util.concurrent.TimeUnit.*;
  
  import java.util.Date;
  
  public class Bootstrap
  {
    public static void main(String[] args)
    {
      addThreadsToPool();
      ServiceTest service1 = new ServiceTest(); 
    }
  
    public static void addThreadsToPool()
    {
      ScheduledThreadPoolExecutor eventPool = new ScheduledThreadPoolExecutor(5);
  
      eventPool.scheduleAtFixedRate(new Updater(), 2, 20, SECONDS);
  
      try {
        Thread.sleep(20000);
      } catch (InterruptedException ignored) {
      }
    }
  }
  </code></pre>
  
  <p>in this example , class Updater executes every 20 seconds , the problem is if updater 's execution takes a period of time more than 20 seconds . 
  So how to make Updater finishes ites task before the next scheduled execution? </p>