persistable sclass SynchronizedSortedMap extends SynchronizedMap implements SortedMap { // not final because persistence private /*final*/ SortedMap sm; SynchronizedSortedMap(SortedMap m) { super(m); sm = m; } SynchronizedSortedMap(SortedMap m, Object mutex) { super(m, mutex); sm = m; } public Comparator comparator() { synchronized (mutex) {return sm.comparator();} } public SortedMap subMap(K fromKey, K toKey) { synchronized (mutex) { return new SynchronizedSortedMap<>( sm.subMap(fromKey, toKey), mutex); } } public SortedMap headMap(K toKey) { synchronized (mutex) { return new SynchronizedSortedMap<>(sm.headMap(toKey), mutex); } } public SortedMap tailMap(K fromKey) { synchronized (mutex) { return new SynchronizedSortedMap<>(sm.tailMap(fromKey),mutex); } } public K firstKey() { synchronized (mutex) {return sm.firstKey();} } public K lastKey() { synchronized (mutex) {return sm.lastKey();} } }