491 |
|
public void testTimedWait_IllegalMonitorException() { |
492 |
|
Thread t = newStartedThread(new CheckedRunnable() { |
493 |
|
public void realRun() throws InterruptedException { |
494 |
– |
long startTime = System.nanoTime(); |
494 |
|
Object o = new Object(); |
496 |
– |
|
495 |
|
try { |
496 |
< |
MILLISECONDS.timedWait(o, LONG_DELAY_MS); |
496 |
> |
MILLISECONDS.timedWait(o, LONGER_DELAY_MS); |
497 |
|
threadShouldThrow(); |
498 |
|
} catch (IllegalMonitorStateException success) {} |
501 |
– |
|
502 |
– |
assertTrue(millisElapsedSince(startTime) < LONG_DELAY_MS); |
499 |
|
}}); |
500 |
|
|
501 |
|
awaitTermination(t); |
508 |
|
final CountDownLatch pleaseInterrupt = new CountDownLatch(1); |
509 |
|
Thread t = newStartedThread(new CheckedRunnable() { |
510 |
|
public void realRun() throws InterruptedException { |
515 |
– |
long startTime = System.nanoTime(); |
511 |
|
Object o = new Object(); |
512 |
|
|
513 |
|
Thread.currentThread().interrupt(); |
514 |
|
try { |
515 |
|
synchronized (o) { |
516 |
< |
MILLISECONDS.timedWait(o, LONG_DELAY_MS); |
516 |
> |
MILLISECONDS.timedWait(o, LONGER_DELAY_MS); |
517 |
|
} |
518 |
|
shouldThrow(); |
519 |
|
} catch (InterruptedException success) {} |
522 |
|
pleaseInterrupt.countDown(); |
523 |
|
try { |
524 |
|
synchronized (o) { |
525 |
< |
MILLISECONDS.timedWait(o, LONG_DELAY_MS); |
525 |
> |
MILLISECONDS.timedWait(o, LONGER_DELAY_MS); |
526 |
|
} |
527 |
|
shouldThrow(); |
528 |
|
} catch (InterruptedException success) {} |
529 |
|
assertFalse(Thread.interrupted()); |
535 |
– |
|
536 |
– |
assertTrue(millisElapsedSince(startTime) < LONG_DELAY_MS); |
530 |
|
}}); |
531 |
|
|
532 |
|
await(pleaseInterrupt); |
542 |
|
final CountDownLatch pleaseInterrupt = new CountDownLatch(1); |
543 |
|
final Thread s = newStartedThread(new CheckedInterruptedRunnable() { |
544 |
|
public void realRun() throws InterruptedException { |
545 |
< |
Thread.sleep(LONG_DELAY_MS); |
545 |
> |
Thread.sleep(LONGER_DELAY_MS); |
546 |
|
}}); |
547 |
|
final Thread t = newStartedThread(new CheckedRunnable() { |
548 |
|
public void realRun() throws InterruptedException { |
556 |
– |
long startTime = System.nanoTime(); |
557 |
– |
|
549 |
|
Thread.currentThread().interrupt(); |
550 |
|
try { |
551 |
< |
MILLISECONDS.timedJoin(s, LONG_DELAY_MS); |
551 |
> |
MILLISECONDS.timedJoin(s, LONGER_DELAY_MS); |
552 |
|
shouldThrow(); |
553 |
|
} catch (InterruptedException success) {} |
554 |
|
assertFalse(Thread.interrupted()); |
555 |
|
|
556 |
|
pleaseInterrupt.countDown(); |
557 |
|
try { |
558 |
< |
MILLISECONDS.timedJoin(s, LONG_DELAY_MS); |
558 |
> |
MILLISECONDS.timedJoin(s, LONGER_DELAY_MS); |
559 |
|
shouldThrow(); |
560 |
|
} catch (InterruptedException success) {} |
561 |
|
assertFalse(Thread.interrupted()); |
571 |
– |
|
572 |
– |
assertTrue(millisElapsedSince(startTime) < LONG_DELAY_MS); |
562 |
|
}}); |
563 |
|
|
564 |
|
await(pleaseInterrupt); |
576 |
|
final CountDownLatch pleaseInterrupt = new CountDownLatch(1); |
577 |
|
Thread t = newStartedThread(new CheckedRunnable() { |
578 |
|
public void realRun() throws InterruptedException { |
590 |
– |
long startTime = System.nanoTime(); |
591 |
– |
|
579 |
|
Thread.currentThread().interrupt(); |
580 |
|
try { |
581 |
< |
MILLISECONDS.sleep(LONG_DELAY_MS); |
581 |
> |
MILLISECONDS.sleep(LONGER_DELAY_MS); |
582 |
|
shouldThrow(); |
583 |
|
} catch (InterruptedException success) {} |
584 |
|
assertFalse(Thread.interrupted()); |
585 |
|
|
586 |
|
pleaseInterrupt.countDown(); |
587 |
|
try { |
588 |
< |
MILLISECONDS.sleep(LONG_DELAY_MS); |
588 |
> |
MILLISECONDS.sleep(LONGER_DELAY_MS); |
589 |
|
shouldThrow(); |
590 |
|
} catch (InterruptedException success) {} |
591 |
|
assertFalse(Thread.interrupted()); |
605 |
– |
|
606 |
– |
assertTrue(millisElapsedSince(startTime) < LONG_DELAY_MS); |
592 |
|
}}); |
593 |
|
|
594 |
|
await(pleaseInterrupt); |