title: Parallel iteration on multiple collections
body: <p>I'm reading J. Bloch's "Effective Java" and now I'm at the section about <code>for-each</code> vs <code>for-loop</code>. He mentioned three cases where we couldn't use the <code>for-each</code> loop and one of them is the following:L</p>
  
  <blockquote>
    <p><strong>Parallel iteration</strong>— If you need to traverse multiple collections in
    parallel, then you need explicit control over the iterator or index
    variable, so that all iterators or index variables can be advanced in
    lockstep (as demonstrated unintentionally in the buggy card and dice
    examples above).</p>
  </blockquote>
  
  <p>The case is not quite clear to me, I can't imagine an example. </p>
  
  <p>The first thought that popped into my head was that it was just about iterating the same collection in multiple threads but it's probably not what he meant. I don't see any restrictions preventing us from doing so (read-only). Actually:</p>
  
  <pre><code>public class MyRunnable implements Runnable{
  
      private Collection&lt;String&gt; col;
  
      //CTOR ommmited
  
      public void run(){
      for(String s : col){
         //print o, not modify
      }
  
  }
  </code></pre>
  
  <p>Then we just start some threads with the same instance. So, we're not afraid of getting <code>ConcurrentModificationException</code> (<a href="http://docs.oracle.com/javase/7/docs/api/java/util/ConcurrentModificationException.html" rel="nofollow">JavaDocs</a>) because we perform read-only access, even by multiple threads simultaneously. </p>
  
  <p>What's wrong?</p>