title: Replace ConcurrentHashMap with EnumMap
body: <p>All the while, I am using <code>ConcurrentHashMap</code>, if I want to achieve the following.</p>
  
  <ol>
  <li>Able to iterate the map without throwing <code>ConcurrentModificationException</code>, while another thread is modifying the map content.</li>
  <li>Allow two modification, by two threads at the same time.</li>
  </ol>
  
  <p>Sometime, I use <code>enum</code> as key, and from <a href="http://download.oracle.com/javase/6/docs/api/java/util/EnumMap.html" rel="noreferrer">EnumMap Javadoc</a>, I realize,</p>
  
  <blockquote>
    <p>Iterators returned by the collection
    views are weakly consistent: they will
    never throw
    ConcurrentModificationException and
    they may or may not show the effects
    of any modifications to the map that
    occur while the iteration is in
    progress.</p>
  </blockquote>
  
  <p>Hence, is it safe for me to replace</p>
  
  <pre><code>Map&lt;Country, String&gt; map =  new ConcurrentHashMap&lt;Country, String&gt;();
  </code></pre>
  
  <p>with</p>
  
  <pre><code>Map&lt;Country, String&gt; map =  Collections.synchronizedMap(new EnumMap&lt;Country, String&gt;(Country.class));
  </code></pre>
  
  <p>I know there is no <code>putIfAbsent</code> in <code>EnumMap</code>, but that is OK for me at this moment as I do not require it.</p>