code: public static <K,V> Map<K,V> synchronizedMap(Map<K,V> m) {
          return new SynchronizedMap<>(m);
      }
docs: Returns a synchronized (thread-safe) map backed by the specified
  map.  In order to guarantee serial access, it is critical that
  <strong>all</strong> access to the backing map is accomplished
  through the returned map.<p>
  
  It is imperative that the user manually synchronize on the returned
  map when iterating over any of its collection views:
  <pre>
  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());
  }
  </pre>
  Failure to follow this advice may result in non-deterministic behavior.
  
  <p>The returned map will be serializable if the specified map is
  serializable.
  
  @param <K> the class of the map keys
  @param <V> the class of the map values
  @param  m the map to be "wrapped" in a synchronized map.
  @return a synchronized view of the specified map.