title: Understanding java executor service shutdown and awaitTermination
body: <p>need to clarify following behaviour. </p>
  
  <p>I have a java app with <code>java.util.concurrent.ExecutorService</code> as follows,</p>
  
  <pre><code>       for (int i = 0; i &lt; thread_count; i++) {
              Runnable worker = new MyThread(batchSize);
              executor.execute(worker);
          }
  
          executor.shutdown();
          executor.awaitTermination(15, TimeUnit.MINUTES);
          System.out.println("All threads are finished");
  </code></pre>
  
  <p>In above code I have 5 threads and those are finished in 10 minutes and it will execute <code>System.out.println("All threads are finished")</code>, even-though <code>executor.awaitTermination(15, TimeUnit.MINUTES)</code> has 15 minutes wait time.</p>
  
  <p>But when I remove <code>executor.shutdown()</code> the program will wait 15 minutes which is specified in <code>executor.awaitTermination(15, TimeUnit.MINUTES)</code> statement, before executing next line. </p>
  
  <p>Can any one explain this behaviour ? Why without shutdown command will wait specified amount of time evengthough all the threads are finished ?</p>