MCPcopy Create free account
hub / github.com/ReadyTalk/avian / main

Method main

test/ConcurrentHashMapTest.java:16–106  ·  view source on GitHub ↗
(String[] args)

Source from the content-addressed store, hash-verified

14 }
15
16 public static void main(String[] args) throws Throwable {
17 final ConcurrentMap<Integer, Object> map = new ConcurrentHashMap();
18 final int[] counter = new int[1];
19 final int[] step = new int[1];
20 final Throwable[] exception = new Throwable[1];
21
22 synchronized (map) {
23 for (int i = 0; i < ThreadCount; ++i) {
24 final int index = i;
25 new Thread() {
26 public void run() {
27 try {
28 synchronized (map) {
29 ++ counter[0];
30 map.notifyAll();
31 while (exception[0] == null && step[0] == 0) {
32 map.wait();
33 }
34 }
35
36 for (int i = 0; i < IterationCount; ++i) {
37 populateCommon(map);
38 populate(map, index * Range);
39 }
40
41 synchronized (map) {
42 -- counter[0];
43 map.notifyAll();
44 while (exception[0] == null && step[0] == 1) {
45 map.wait();
46 }
47 }
48
49 for (int i = 0; i < IterationCount; ++i) {
50 populate(map, index * Range);
51 depopulate(map, index * Range);
52 }
53
54 synchronized (map) {
55 ++ counter[0];
56 map.notifyAll();
57 }
58 } catch (Throwable e) {
59 synchronized (map) {
60 exception[0] = e;
61 map.notifyAll();
62 }
63 e.printStackTrace();
64 }
65 }
66 }.start();
67 }
68
69 try {
70 while (exception[0] == null && counter[0] < ThreadCount) {
71 map.wait();
72 }
73

Callers

nothing calls this directly

Calls 8

sizeMethod · 0.95
expectMethod · 0.95
containsKeyMethod · 0.95
isEmptyMethod · 0.95
startMethod · 0.45
waitMethod · 0.45
notifyAllMethod · 0.45
printlnMethod · 0.45

Tested by

no test coverage detected