Collections.synchronizedMap
<p>From <a href="http://docs.oracle.com/javase/7/docs/api/java/util/Collections.html#synchronizedMap%28java.util.Map%29" rel="nofollow">javadocs</a></p>

<pre><code>Map m = Collections.synchronizedMap(new HashMap());
      ...
  Set s = m.keySet();  // Needn't be in synchronized block
      ...
  synchronized(m) {  // Synchronizing on m, not s!
      Iterator i = s.iterator(); // Must be in synchronized block
      while (i.hasNext())
          foo(i.next());
  }
</code></pre>

<p>Two queries:</p>

<p>1) Is Set returned by m.keySet() also a collection wrapper or just an unsynchronized set?</p>

<p><strong>EDIT:</strong></p>

<p>2)Is it necessary to synchronize on m in</p>

<pre><code> synchronized(m) {  // Synchronizing on m, not s!
</code></pre>

<p>Can't we synchronize on s instead of m?</p>
