title: ExecutorService awaitTermination shutdown signal in the Runnable instance
body: <p>I've a few questions around <code>ExecutorService</code> and the shutdown process.
  My use case:
  I use an <code>ExecutorService</code> to spawn a fixed number of threads whose run method look like this:</p>
  
  <pre><code>while (true) {
     try {
        this.currentThreadRunning = true;
        processMessage();
     }
     catch (Throwable e) {
        // Keeping the thread alive despite exceptions.
     }
  }
  </code></pre>
  
  <p>These threads run infinitely, polling for messages.</p>
  
  <p>What am I trying to do?
  I am polling an SQS queue for messages and processing them.</p>
  
  <p>Obviously, in my case, the <code>ExecutorService's</code> shutdown method would not work. When <code>shutdownNow()</code> is called, all my threads are shutdown unceremoniously. I hate it! </p>
  
  <p>Is there a way to invoke <code>awaitTermination</code> and verify, in my <code>Runnable</code> instance(in a finally block?), if shutdown has been initiated and trigger the same for the current thread?</p>
  
  <p>UPDATE: I've refactored my code to perform polling and then spawning threads to process them. Thus, the Runnable instance's run method need not be an endless loop. And <code>awaiTermination</code> will lead to a definite closure of the threads. And to be sure, I've triggered <code>shutdownNow</code> after <code>awaitTermination</code>.</p>