1 |
|
/* |
2 |
|
* Written by Doug Lea with assistance from members of JCP JSR-166 |
3 |
|
* Expert Group and released to the public domain, as explained at |
4 |
< |
* http://creativecommons.org/licenses/publicdomain |
4 |
> |
* http://creativecommons.org/publicdomain/zero/1.0/ |
5 |
|
* Other contributors include Andrew Wright, Jeffrey Hayes, |
6 |
|
* Pat Fisher, Mike Judd. |
7 |
|
*/ |
120 |
|
|
121 |
|
t1.start(); |
122 |
|
t2.start(); |
123 |
< |
Thread.sleep(SHORT_DELAY_MS); |
123 |
> |
delay(SHORT_DELAY_MS); |
124 |
|
t1.interrupt(); |
125 |
|
t1.join(); |
126 |
|
t2.join(); |
143 |
|
|
144 |
|
t1.start(); |
145 |
|
t2.start(); |
146 |
< |
Thread.sleep(SHORT_DELAY_MS); |
146 |
> |
delay(SHORT_DELAY_MS); |
147 |
|
t1.interrupt(); |
148 |
|
t1.join(); |
149 |
|
t2.join(); |
152 |
|
/** |
153 |
|
* A timeout in timed await throws TimeoutException |
154 |
|
*/ |
155 |
< |
public void testAwait3_TimeOutException() throws InterruptedException { |
155 |
> |
public void testAwait3_TimeoutException() throws InterruptedException { |
156 |
|
final CyclicBarrier c = new CyclicBarrier(2); |
157 |
|
Thread t = new ThreadShouldThrow(TimeoutException.class) { |
158 |
|
public void realRun() throws Exception { |
222 |
|
|
223 |
|
t1.start(); |
224 |
|
t2.start(); |
225 |
< |
Thread.sleep(SHORT_DELAY_MS); |
225 |
> |
delay(SHORT_DELAY_MS); |
226 |
|
c.reset(); |
227 |
|
t1.join(); |
228 |
|
t2.join(); |
277 |
|
|
278 |
|
t.start(); |
279 |
|
for (int i = 0; i < 4; i++) { |
280 |
< |
Thread.sleep(SHORT_DELAY_MS); |
280 |
> |
delay(SHORT_DELAY_MS); |
281 |
|
t.interrupt(); |
282 |
|
} |
283 |
|
done.set(true); |
355 |
|
* Reset of a barrier after timeout reinitializes it. |
356 |
|
*/ |
357 |
|
public void testResetAfterTimeout() throws Exception { |
358 |
< |
final CyclicBarrier start = new CyclicBarrier(3); |
358 |
> |
final CyclicBarrier start = new CyclicBarrier(2); |
359 |
|
final CyclicBarrier barrier = new CyclicBarrier(3); |
360 |
|
for (int i = 0; i < 2; i++) { |
361 |
|
Thread t1 = new ThreadShouldThrow(TimeoutException.class) { |
362 |
|
public void realRun() throws Exception { |
363 |
|
start.await(); |
364 |
< |
barrier.await(MEDIUM_DELAY_MS, MILLISECONDS); |
364 |
> |
barrier.await(SHORT_DELAY_MS, MILLISECONDS); |
365 |
|
}}; |
366 |
|
|
367 |
|
Thread t2 = new ThreadShouldThrow(BrokenBarrierException.class) { |
372 |
|
|
373 |
|
t1.start(); |
374 |
|
t2.start(); |
375 |
– |
start.await(); |
375 |
|
t1.join(); |
376 |
|
t2.join(); |
377 |
|
assertTrue(barrier.isBroken()); |