title: ExecutorService shutdown hook
body: <p>I have console application with following threading code. It seems when i hit <strong><em>Ctrl+C</em></strong> to terminate it does not detect control keys, i have to close command prompt window.</p>
  
  <p><em><strong>Any clues why it is not detecting ctrl+c?</em></strong></p>
  
  <pre><code>            final ExecutorService executor = Executors.newFixedThreadPool(threadPoolSize);
          final long SHUTDOWN_TIME = TimeUnit.SECONDS.toMillis(10);
          for (int i = 0; i &lt; threadPoolSize; i++) {
              executor.submit(new MessageWorker(topicSubscriber));
          }
          //--
          //Add JVM shutdown hook
          Runtime.getRuntime().addShutdownHook(new Thread() {
              /**
               * @see java.lang.Thread#run()
               */
              @Override
              public void run() {
                  executor.shutdown();
                  try {
                      if (!executor.awaitTermination(SHUTDOWN_TIME, TimeUnit.SECONDS)) {
                          log.warn("Executor did not terminate in the specified time.");
                          List&lt;Runnable&gt; droppedTasks = executor.shutdownNow();
                          log.warn("Executor was abruptly shut down. " + droppedTasks.size() + " tasks will not be executed.");
                      }
                  } catch (InterruptedException e) {
                      e.printStackTrace();
                  }
              }
          });
  </code></pre>