title: ExecutorService.submit(<callable>) taking more time?
body: <p>I am trying to understand the utilities in <code>java.util.concurrent</code> package and learnt that we can submit <code>callable</code> objects to the <code>ExecutorService</code>, which returns <code>Future</code>, which is filled with the value returned by the <code>callable</code>, after successful completion of task within <code>call()</code> method.</p>
  
  <p>I am understanding that all the callables are executed concurrently using multiple threads.</p>
  
  <p>When I wanted to see how much improvement <code>ExecutorService</code> gives over the batch task execution, i thought of capturing time.</p>
  
  <p>Following is the code which i tried to execute - </p>
  
  <pre><code>package concurrency;
  
  
  import java.util.ArrayList;
  import java.util.List;
  import java.util.concurrent.Callable;
  import java.util.concurrent.ExecutionException;
  import java.util.concurrent.ExecutorService;
  import java.util.concurrent.Executors;
  import java.util.concurrent.Future;
  
  
  public class ExecutorExample {
  
      private static Callable&lt;String&gt; callable = new Callable&lt;String&gt;() {
  
          @Override
          public String call() throws Exception {
              StringBuilder builder = new StringBuilder();
              for(int i=0; i&lt;5; i++) {
                  builder.append(i);
              }
              return builder.toString();
          }
      };
  
      public static void main(String [] args) {
          long start = System.currentTimeMillis();
          ExecutorService service = Executors.newFixedThreadPool(5);
          List&lt;Future&lt;String&gt;&gt; futures = new ArrayList&lt;Future&lt;String&gt;&gt;();
          for(int i=0; i&lt;5; i++) {
              Future&lt;String&gt; value = service.submit(callable);
              futures.add(value);
          }
          for(Future&lt;String&gt; f : futures) {
              try {
                  System.out.println(f.isDone() + " " + f.get());
              } catch (InterruptedException e) {
                  // TODO Auto-generated catch block
                  e.printStackTrace();
              } catch (ExecutionException e) {
                  // TODO Auto-generated catch block
                  e.printStackTrace();
              }
          }
          long end  = System.currentTimeMillis();
          System.out.println("Executer callable time - " + (end - start));
          service.shutdown();
  
          start = System.currentTimeMillis();
          for(int i=0; i&lt;5; i++) {
              StringBuilder builder = new StringBuilder();
              for(int j=0; j&lt;5; j++) {
                  builder.append(j);
              }
              System.out.println(builder.toString());
          }
          end = System.currentTimeMillis();
          System.out.println("Normal time - " + (end - start));
      }
  
  }
  </code></pre>
  
  <p>and here is the output of this - </p>
  
  <pre><code>true 01234
  true 01234
  true 01234
  true 01234
  true 01234
  Executer callable time - 5
  01234
  01234
  01234
  01234
  01234
  Normal time - 0
  </code></pre>
  
  <p>Please let me know if I am missing something OR understanding something in a wrong way.</p>
  
  <p>Thanks in advance for your time and help for this thread.</p>