title: Java ThreadPoolExecutors idle thread shutdown - calling custom cleanup code
body: <p>Per the ThreadPoolExecutor doc (<a href="http://docs.oracle.com/javase/7/docs/api/java/util/concurrent/ThreadPoolExecutor.html" rel="nofollow">Java ThreadPoolExecutor</a>), if I create an executor service like so:</p>
  
  <pre><code>new ThreadPoolExecutor(corePoolSize, maximumPoolSize, keepAliveTime, unit, workQueue);
  </code></pre>
  
  <p>and when #threads > corePoolSize, idle threads will be killed. I wanted to call some application specific cleanup code when the ThreadPoolExecutor kills any thread. I wasn't able to get a clear way to do so. Appreciate any help. Thanks in advance.</p>