title: ScheduledExecutorService end after a timeout
body: <p>Good day! I have scheduler and I need to check how much time does it works. How can I do that? I need to return an error from someFunction() when scheduler works more than 5 minutes </p>
  
  <pre><code>ScheduledExecutorService scheduler = Executors.newScheduledThreadPool(1);
  
  public int someFunction() {
      ScheduledFuture&lt;Integer&gt; future = 
          scheduler.schedule(new ScheduledPrinter(), 10, TimeUnit.SECONDS);
      if (scheduler.isShutdown()) {
          return future.get();
      }
  }
  private class ScheduledPrinter implements Callable&lt;Integer&gt; {
      public Integer call() throws Exception {
          // do something
          if (!serverResponse.getErrorData().equals("QueueIsNotReady")) {
              scheduler.shutdown();
              return getResponse();
          } 
          return null;
      }
  }
  </code></pre>