title: WeakHashMap and Concurrent Modification
body: <p>I'm reading the Java Doc about the <a href="https://docs.oracle.com/javase/8/docs/api/java/util/WeakHashMap.html" rel="nofollow noreferrer">WeakHashMap</a>  and I get the basic concept. 
  Because of the GC thread(s) acting in the background, you can get 'unusual behavior', such as a ConcurrentModificationException when iterating and etc. </p>
  
  <p>The thing I don't get is that if the default implementation is not synchronized and does not contain lock in any way, then how come there is no possibility of getting an inconsistent state. 
  Say you have 2 threads. A GC thread deleting some key at a certain index and at same time and at the same index, a user thread is inserting in the array a key value pair.</p>
  
  <p>To me, if there is no synchronization, then there is a high risk of getting a hash map that is inconsistent.</p>
  
  <p>Even worse, doing something like this might actually be super dangerous because v might actually be null.</p>
  
  <pre><code>if (map.contains(k)) {
     V v = map.get(k)
  }
  </code></pre>
  
  <p>Am I missing something?</p>