title: How does Keep-alive work with ThreadPoolExecutor?
body: <p>In continuation to a <a href="https://stackoverflow.com/q/10346187/181870" title="How to implement an ExecutorService to execute tasks on a rotation-basis?">question</a> posted by me, I'm trying to use <a href="http://docs.oracle.com/javase/6/docs/api/java/util/concurrent/ThreadPoolExecutor.html" rel="noreferrer">ThreadPoolExecutor</a> in my codebase.  Even after repeated attempts to comprehend from Java API doc,  I failed to understand clearly the functionality/purpose behind <code>keepAliveTime</code> parameter to be passed in the constructor.  Hope somebody can explain me with some good working example.</p>
  
  <p><strong>Excerpts from Java doc:</strong></p>
  
  <pre><code>public ThreadPoolExecutor(int corePoolSize,
                            int maximumPoolSize,
                            long keepAliveTime,
                            TimeUnit unit,
                            BlockingQueue&lt;Runnable&gt; workQueue)
  </code></pre>
  
  <p><strong><em><code>keepAliveTime</code></em></strong> - <em>when the number of threads is greater than the core, this is the maximum time that excess idle threads will wait for new tasks before terminating.</em></p>