Package java.util
Class Collections
static Map synchronizedMap(Map m)
_INSERT_METHOD_SIGNATURE_HERE_
Description:
Returns a synchronized (thread-safe) map backed by the specified map. Changes in the returned sorted map are reflected in this map, and vice-versa. In order to guarantee serial access, it is critical that all access to the backing map is accomplished through the returned map.
The user has to manually synchronize on the returned map when iterating over it:
Set s = MyMap.keySet(); // doesn't have to be in the synchronized block
synchronized(MyMap) { // iterate in a synchronized block
Iterator i = s.iterator();
while (i.hasNext())
myFun(i.next());
}
The returned collection will be serializable if the specified map is serializable.