title: Java synchronized list for loop
body: <p>Documentation on synchronizedList states that,</p>
  
  <p><em>It is imperative that the user manually synchronize on the returned list when iterating over it:</em></p>
  
  <pre><code>List list = Collections.synchronizedList(new ArrayList());
  ...
  synchronized(list) {
      Iterator i = list.iterator(); // Must be in synchronized block
      while (i.hasNext())
      foo(i.next());
  }
  </code></pre>
  
  <p><em>Failure to follow this advice may result in non-deterministic behavior.</em></p>
  
  <p>This seems pretty clear, but I just wanted to confirm that a for each loop is prohibited.  For example, I cannot do something like as follows right?</p>
  
  <pre><code>List&lt;MyType&gt; list = Collections.synchronizedList(new ArrayList(&lt;MyType&gt;));
  ...
  synchronized(list){
      for(MyType m : list){
          foo(m);
          m.doSomething();
      }
  }
  </code></pre>