66 |
|
|
67 |
|
t.start(); |
68 |
|
assertEquals(l.getCount(), 2); |
69 |
< |
Thread.sleep(SHORT_DELAY_MS); |
69 |
> |
delay(SHORT_DELAY_MS); |
70 |
|
l.countDown(); |
71 |
|
assertEquals(l.getCount(), 1); |
72 |
|
l.countDown(); |
74 |
|
t.join(); |
75 |
|
} |
76 |
|
|
77 |
– |
|
77 |
|
/** |
78 |
|
* timed await returns after countDown to zero |
79 |
|
*/ |
88 |
|
|
89 |
|
t.start(); |
90 |
|
assertEquals(l.getCount(), 2); |
91 |
< |
Thread.sleep(SHORT_DELAY_MS); |
91 |
> |
delay(SHORT_DELAY_MS); |
92 |
|
l.countDown(); |
93 |
|
assertEquals(l.getCount(), 1); |
94 |
|
l.countDown(); |
125 |
|
}}); |
126 |
|
|
127 |
|
t.start(); |
128 |
< |
Thread.sleep(SHORT_DELAY_MS); |
128 |
> |
delay(SHORT_DELAY_MS); |
129 |
|
assertEquals(l.getCount(), 1); |
130 |
|
t.interrupt(); |
131 |
|
t.join(); |
153 |
|
*/ |
154 |
|
public void testToString() { |
155 |
|
CountDownLatch s = new CountDownLatch(2); |
156 |
< |
String us = s.toString(); |
158 |
< |
assertTrue(us.indexOf("Count = 2") >= 0); |
156 |
> |
assertTrue(s.toString().contains("Count = 2")); |
157 |
|
s.countDown(); |
158 |
< |
String s1 = s.toString(); |
161 |
< |
assertTrue(s1.indexOf("Count = 1") >= 0); |
158 |
> |
assertTrue(s.toString().contains("Count = 1")); |
159 |
|
s.countDown(); |
160 |
< |
String s2 = s.toString(); |
164 |
< |
assertTrue(s2.indexOf("Count = 0") >= 0); |
160 |
> |
assertTrue(s.toString().contains("Count = 0")); |
161 |
|
} |
162 |
|
|
163 |
|
} |