581 |
|
} |
582 |
|
|
583 |
|
/** |
584 |
< |
* timedSleep throws InterruptedException when interrupted |
584 |
> |
* timeUnit.sleep throws InterruptedException when interrupted |
585 |
|
*/ |
586 |
|
public void testTimedSleep_Interruptible() { |
587 |
|
final CountDownLatch pleaseInterrupt = new CountDownLatch(1); |
613 |
|
} |
614 |
|
|
615 |
|
/** |
616 |
+ |
* timeUnit.sleep(x) for x <= 0 does not sleep at all. |
617 |
+ |
*/ |
618 |
+ |
public void testTimedSleep_nonPositive() throws InterruptedException { |
619 |
+ |
long startTime = System.nanoTime(); |
620 |
+ |
boolean interrupt = randomBoolean(); |
621 |
+ |
if (interrupt) Thread.currentThread().interrupt(); |
622 |
+ |
randomTimeUnit().sleep(0L); |
623 |
+ |
randomTimeUnit().sleep(-1L); |
624 |
+ |
randomTimeUnit().sleep(Long.MIN_VALUE); |
625 |
+ |
if (interrupt) assertTrue(Thread.interrupted()); |
626 |
+ |
} |
627 |
+ |
|
628 |
+ |
/** |
629 |
|
* a deserialized/reserialized unit is the same instance |
630 |
|
*/ |
631 |
|
public void testSerialization() throws Exception { |