40 |
|
public void testConstructor2() { |
41 |
|
try { |
42 |
|
new Phaser(-1); |
43 |
< |
this.shouldThrow(); |
43 |
> |
shouldThrow(); |
44 |
|
} catch (IllegalArgumentException success) { |
45 |
|
} |
46 |
|
} |
230 |
|
Phaser phaser = new Phaser(); |
231 |
|
phaser.arriveAndDeregister(); |
232 |
|
shouldThrow(); |
233 |
– |
|
233 |
|
} catch (IllegalStateException success) { |
234 |
|
} |
235 |
|
} |
324 |
|
* phaser |
325 |
|
*/ |
326 |
|
public void testAwaitAdvance2() { |
327 |
< |
try { |
328 |
< |
Phaser phaser = new Phaser(); |
330 |
< |
phaser.awaitAdvance(-1); |
331 |
< |
} catch (Exception failure) { |
332 |
< |
this.unexpectedException(); |
333 |
< |
} |
327 |
> |
Phaser phaser = new Phaser(); |
328 |
> |
phaser.awaitAdvance(-1); |
329 |
|
} |
330 |
|
|
331 |
|
/** |
332 |
|
* awaitAdvance while waiting does not abort on interrupt. |
333 |
|
*/ |
334 |
< |
public void testAwaitAdvance3() { |
334 |
> |
public void testAwaitAdvance3() throws InterruptedException { |
335 |
|
final Phaser phaser = new Phaser(); |
336 |
|
|
337 |
|
Thread th1 = new Thread(new CheckedRunnable() { |
342 |
|
}}); |
343 |
|
phaser.register(); |
344 |
|
th1.start(); |
345 |
< |
try { |
346 |
< |
Thread.sleep(SHORT_DELAY_MS); |
347 |
< |
th1.interrupt(); |
348 |
< |
Thread.sleep(LONG_DELAY_MS); |
354 |
< |
phaser.arrive(); |
355 |
< |
} catch (InterruptedException failure) { |
356 |
< |
threadUnexpectedException(failure); |
357 |
< |
} |
345 |
> |
Thread.sleep(SHORT_DELAY_MS); |
346 |
> |
th1.interrupt(); |
347 |
> |
Thread.sleep(LONG_DELAY_MS); |
348 |
> |
phaser.arrive(); |
349 |
|
assertFalse(th1.isInterrupted()); |
350 |
|
} |
351 |
|
|
386 |
|
void realRun() { |
387 |
|
getRunnable(SHORT_DELAY_MS).run(); |
388 |
|
phaser.arrive(); |
389 |
< |
} |
399 |
< |
}).start(); |
389 |
> |
}}).start(); |
390 |
|
phase = phaser.awaitAdvance(phaser.arrive()); |
391 |
|
threadAssertEquals(phase, phaser.getPhase()); |
392 |
|
} |
447 |
|
/** |
448 |
|
* Interrupted arriveAndAwaitAdvance does not throw InterruptedException |
449 |
|
*/ |
450 |
< |
public void testArriveAndAwaitAdvance2() { |
450 |
> |
public void testArriveAndAwaitAdvance2() throws InterruptedException { |
451 |
|
final Phaser phaser = new Phaser(2); |
452 |
|
Thread th = new Thread(new CheckedRunnable() { |
453 |
|
void realRun() { |
454 |
|
phaser.arriveAndAwaitAdvance(); |
455 |
|
}}); |
456 |
|
|
457 |
< |
try { |
458 |
< |
th.start(); |
459 |
< |
Thread.sleep(LONG_DELAY_MS); |
460 |
< |
th.interrupt(); |
461 |
< |
Thread.sleep(LONG_DELAY_MS); |
472 |
< |
phaser.arrive(); |
473 |
< |
} catch (InterruptedException failure) { |
474 |
< |
this.unexpectedException(); |
475 |
< |
} |
457 |
> |
th.start(); |
458 |
> |
Thread.sleep(LONG_DELAY_MS); |
459 |
> |
th.interrupt(); |
460 |
> |
Thread.sleep(LONG_DELAY_MS); |
461 |
> |
phaser.arrive(); |
462 |
|
assertFalse(th.isInterrupted()); |
463 |
|
} |
464 |
|
|