sclass MapInConcept implements Map { Map m; // Backing Map Concept cc; *() {} // for persistence *(Map *m, Concept *cc) {} public int size() { synchronized (this) {return m.size();} } public boolean isEmpty() { synchronized (this) {return m.isEmpty();} } public boolean containsKey(Object key) { synchronized (this) {return m.containsKey(key);} } public boolean containsValue(Object value) { synchronized (this) {return m.containsValue(value);} } public V get(Object key) { synchronized (this) {return m.get(key);} } public V put(K key, V value) { try { synchronized (this) {return m.put(key, value);} } finally { cc.change(); } } public V remove(Object key) { try { synchronized (this) {return m.remove(key);} } finally { cc.change(); } } public void putAll(Map map) { synchronized (this) {m.putAll(map);} cc.change(); } public void clear() { synchronized (this) {m.clear();} cc.change(); } private transient Set keySet; private transient Set> entrySet; private transient Collection values; public Set keySet() { synchronized (this) { if (keySet==null) keySet = new SynchronizedSet(m.keySet(), this); return keySet; } } public Set> entrySet() { synchronized (this) { if (entrySet==null) entrySet = new SynchronizedSet(m.entrySet(), this); return entrySet; } } public Collection values() { synchronized (this) { if (values==null) values = new SynchronizedCollection(m.values(), this); return values; } } public boolean equals(Object o) { if (this == o) return true; synchronized (this) {return m.equals(o);} // TODO: deadlock? } public int hashCode() { synchronized (this) {return m.hashCode();} } public String toString() { synchronized (this) {return m.toString();} } // 1.8 stuff omitted Map unwrap() { ret m; } }