title: How does the shutdown work in executors?
body: <p>I have a <code>ScheduledExecutorService</code> and I do a task every 15 mins (in a web application in Tomcat).<br>
  In a <code>ServletContextListener</code> in <code>contextDestroyed</code> I have done:  </p>
  
  <pre><code>Runtime.getRuntime().addShutdownHook(new Thread(){  
              @Override  
              public void run(){  
                  scheduler.shutdown();   
              }   
          });    
  </code></pre>
  
  <p>The scheduler is started like:  </p>
  
  <pre><code>final Runnable r = new Runnable(){
  
              @Override
              public void run() {
                  System.out.println("My task");
                  //Do some task
              }
  
          };
  updater.scheduleWithFixedDelay(r, 30, 15, TimeUnit.MINUTES);
  </code></pre>
  
  <p>Question:On <code>shutdown</code> any remaining task isn't executed.<br>
  There is a task running but I don't see any logs so it seems it is not executed. Why?  </p>
  
  <p><strong>UPDATE:</strong><br>
  If I start tomcat and then after 2 mins I shutdown then isn't the task considered as scheduled and must run?  I mean if a task is submitted isn't it considered as pending? Or it must be actually running?</p>