nMap m = Collections.synchronizedMap(new HashMap());
n ...
nSet s = m.keySet();
// Needn't be in synchronized block
n ...
nsynchronized(m) { // Synchronizing on m, not
s!
n Iterator i =
s.iterator(); // Must be in synchronized block
n
while(i.hasNext())
n
foo(i.next());
n}