2526272829303132333435
new Thread() { public void run() { try { synchronized (map) { ++ counter[0]; map.notifyAll(); while (exception[0] == null && step[0] == 0) { map.wait(); } }
3839404142434445464748
populate(map, index * Range); } synchronized (map) { -- counter[0]; map.notifyAll(); while (exception[0] == null && step[0] == 1) { map.wait(); } }
5152535455565758596061
depopulate(map, index * Range); } synchronized (map) { ++ counter[0]; map.notifyAll(); } } catch (Throwable e) { synchronized (map) { exception[0] = e; map.notifyAll();
5657585960616263646566
map.notifyAll(); } } catch (Throwable e) { synchronized (map) { exception[0] = e; map.notifyAll(); } e.printStackTrace(); } } }.start();
7071727374757677787980
while (exception[0] == null && counter[0] < ThreadCount) { map.wait(); } step[0] = 1; map.notifyAll(); while (exception[0] == null && counter[0] > 0) { map.wait(); }
8687888990919293949596
for (int i = CommonBase, j = CommonBase + Range; i < j; ++i) { expect(! map.containsKey(i)); } step[0] = 2; map.notifyAll(); while (exception[0] == null && counter[0] < ThreadCount) { map.wait(); }
9899100101102103104105106107108
expect(exception[0] == null); } catch (Throwable e) { exception[0] = e; throw e; } finally { map.notifyAll(); } } } private static void populateCommon(ConcurrentMap<Integer, Object> map) {