title: When does parallel processing overcome sequential processing?
body: <pre><code>//    parallel processing
  
      int processors = Runtime.getRuntime().availableProcessors();
      ExecutorService executorService = Executors.newFixedThreadPool(threads);
  
  
      final List&lt;String&gt; albumIds2 = new ArrayList&lt;String&gt;();
      long start2 = System.nanoTime();
      for (final HColumn&lt;String, String&gt; column : result.get().getColumns()) {
          Runnable worker = new Runnable() {
  
              @Override
              public void run() {
                  albumIds2.add(column.getName());
              }
          };
          executorService.execute(worker);
      }
      long timeTaken2 = System.nanoTime() - start2;
  </code></pre>
  
  <p>i have code like the above example which creates a <code>List&lt;String&gt;</code> of album ids.
  the column is a slice from cassandra database.
  i record the time taken for the whole list of albums to be created.</p>
  
  <p>the same i have done using the enhanced for loop like below.</p>
  
  <pre><code>        QueryResult&lt;ColumnSlice&lt;String, String&gt;&gt; result =  CassandraDAO.getRowColumns(AlbumIds_CF, customerId);
      long start = System.nanoTime();
      for (HColumn&lt;String, String&gt; column : result.get().getColumns()) {
          albumIds.add(column.getName());
      }
      long timeTaken = System.nanoTime() - start;
  </code></pre>
  
  <p>i am noting that no matter how large the number of albums, the for each loop always taking a shorter time to complete. Am i doing it wrong? or do i need a computer with multiple cores. I am really new to the whole concept of parallel computing please do pardon me if my question is stupid.</p>