code: public static <K,V> SortedMap<K,V> synchronizedSortedMap(SortedMap<K,V> m) {
          return new SynchronizedSortedMap<>(m);
      }
docs: Returns a synchronized (thread-safe) sorted map backed by the specified
  sorted map.  In order to guarantee serial access, it is critical that
  <strong>all</strong> access to the backing sorted map is accomplished
  through the returned sorted map (or its views).<p>
  
  It is imperative that the user manually synchronize on the returned
  sorted map when iterating over any of its collection views, or the
  collections views of any of its <tt>subMap</tt>, <tt>headMap</tt> or
  <tt>tailMap</tt> views.
  <pre>
  SortedMap m = Collections.synchronizedSortedMap(new TreeMap());
  ...
  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>
  or:
  <pre>
  SortedMap m = Collections.synchronizedSortedMap(new TreeMap());
  SortedMap m2 = m.subMap(foo, bar);
  ...
  Set s2 = m2.keySet();  // Needn't be in synchronized block
  ...
  synchronized (m) {  // Synchronizing on m, not m2 or s2!
  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 sorted map will be serializable if the specified
  sorted map is serializable.
  
  @param <K> the class of the map keys
  @param <V> the class of the map values
  @param  m the sorted map to be "wrapped" in a synchronized sorted map.
  @return a synchronized view of the specified sorted map.