title: How do I get FutureTask to return after TimeoutException?
body: <p>In the code below, I'm catching a TimeoutException after 100 seconds as intended.  At this point I would expect the code to exit from main and the program to terminate but it keeps printing to the console. How do I get the task to stop executing after timeout?</p>
  
  <pre><code>private static final ExecutorService THREAD_POOL = Executors.newCachedThreadPool();
  
  private static &lt;T&gt; T timedCall(Callable&lt;T&gt; c, long timeout, TimeUnit timeUnit) throws InterruptedException, ExecutionException, TimeoutException {
      FutureTask&lt;T&gt; task = new FutureTask&lt;T&gt;(c);
      THREAD_POOL.execute(task);
      return task.get(timeout, timeUnit);
  }
  
  
  public static void main(String[] args) {
  
      try {
          int returnCode = timedCall(new Callable&lt;Integer&gt;() {
              public Integer call() throws Exception {
                  for (int i=0; i &lt; 1000000; i++) {
                      System.out.println(new java.util.Date());
                      Thread.sleep(1000);
                  }
                  return 0;
              }
          }, 100, TimeUnit.SECONDS);
      } catch (Exception e) {
          e.printStackTrace();
          return;
      }
  
  
  }
  </code></pre>