title: Thread-safe iteration over a collection
body: <p>We all know when using <code>Collections.synchronizedXXX</code> (e.g. <code>synchronizedSet()</code>) we get a synchronized "view" of the underlying collection.</p>
  
  <p>However, the document of these wrapper generation methods <strong>states that we have to explicitly synchronize on the collection</strong> when iterating of the collections using an iterator.</p>
  
  <p>Which option do you choose to solve this problem? </p>
  
  <p>I can only see the following approaches:</p>
  
  <ol>
  <li>Do it as the documentation states: synchronize on the collection</li>
  <li>Clone the collection before calling <code>iterator()</code></li>
  <li>Use a collection which iterator is thread-safe (I am only aware of <code>CopyOnWriteArrayList</code>/Set)</li>
  </ol>
  
  <p>And as a bonus question: when using a synchronized view - is the use of foreach/Iterable thread-safe?</p>