title: iterating over and removing from a map
body: <p>I was doing:</p>
  <pre><code>for (Object key : map.keySet())
      if (something)
          map.remove(key);
  </code></pre>
  <p>which threw a ConcurrentModificationException, so i changed it to:</p>
  <pre><code>for (Object key : new ArrayList&lt;Object&gt;(map.keySet()))
      if (something)
          map.remove(key);
  </code></pre>
  <p>this, and any other procedures that modify the map are in synchronized blocks.</p>
  <p><strong>is there a better solution?</strong></p>