title: ExecutorService vs ThreadPoolExecutor using LinkedBlockingQueue
body: <p>I am working on a multithreaded project in which I need to spawn multiple threads to measure the end to end performance of my client code, as I'm doing Load and Performance testing. So I created the below code which is using <code>ExecutorService</code>.</p>
  
  <p>Below is the code with <code>ExecutorService</code>:</p>
  
  <pre><code>public class MultithreadingExample {
  
      public static void main(String[] args) throws InterruptedException {
  
          ExecutorService executor = Executors.newFixedThreadPool(20);
          for (int i = 0; i &lt; 100; i++) {
              executor.submit(new NewTask());
          }
  
          executor.shutdown();
          executor.awaitTermination(Long.MAX_VALUE, TimeUnit.DAYS);
      }
  }
  
  class NewTask implements Runnable {
  
      @Override
      public void run() {
          //Measure the end to end latency of my client code
      }   
  }
  </code></pre>
  
  <p><strong>Problem statement:</strong></p>
  
  <p>Now I was reading some article on the Internet. I found out there is <code>ThreadPoolExecutor</code> as well. So I got confused which one I should be using.</p>
  
  <p>If I replace my above code from:</p>
  
  <pre><code>ExecutorService executor = Executors.newFixedThreadPool(20);
      for (int i = 0; i &lt; 100; i++) {
          executor.submit(new NewTask());
      }
  </code></pre>
  
  <p>to:</p>
  
  <pre><code>BlockingQueue&lt;Runnable&gt; threadPool = new LinkedBlockingQueue&lt;Runnable&gt;();
  
  ThreadPoolExecutor tpExecutor = new ThreadPoolExecutor(20, 2000, 0L, TimeUnit.MILLISECONDS, threadPool);
  
  tpExecutor.prestartAllCoreThreads();
  
      for (int i = 0; i &lt; 100; i++) {
          tpExecutor.execute(new NewTask());
      }
  </code></pre>
  
  <p>will this make any difference? I am trying to understand what is the difference between my original code using <code>ExecutorService</code> and the new code pasted using <code>ThreadPoolExecutor</code>. Some of my team mates said second one (ThreadPoolExecutor) is the right way to use.</p>
  
  <p>Can anyone clarify this for me?</p>