18 |
|
|
19 |
|
public class SemaphoreTest extends JSR166TestCase { |
20 |
|
public static void main(String[] args) { |
21 |
< |
junit.textui.TestRunner.run(suite()); |
21 |
> |
main(suite(), args); |
22 |
|
} |
23 |
|
public static Test suite() { |
24 |
|
return new TestSuite(SemaphoreTest.class); |
467 |
|
clone.release(); |
468 |
|
assertEquals(2, s.availablePermits()); |
469 |
|
assertEquals(1, clone.availablePermits()); |
470 |
+ |
assertFalse(s.hasQueuedThreads()); |
471 |
+ |
assertFalse(clone.hasQueuedThreads()); |
472 |
+ |
} catch (InterruptedException e) { threadUnexpectedException(e); } |
473 |
|
|
474 |
< |
s = new Semaphore(0, fair); |
474 |
> |
{ |
475 |
> |
PublicSemaphore s = new PublicSemaphore(0, fair); |
476 |
|
Thread t = newStartedThread(new InterruptibleLockRunnable(s)); |
477 |
< |
waitForQueuedThreads(s); |
478 |
< |
clone = serialClone(s); |
477 |
> |
// waitForQueuedThreads(s); // suffers from "flicker", so ... |
478 |
> |
waitForQueuedThread(s, t); // ... we use this instead |
479 |
> |
PublicSemaphore clone = serialClone(s); |
480 |
|
assertEquals(fair, s.isFair()); |
481 |
|
assertEquals(fair, clone.isFair()); |
482 |
|
assertEquals(0, s.availablePermits()); |
487 |
|
awaitTermination(t); |
488 |
|
assertFalse(s.hasQueuedThreads()); |
489 |
|
assertFalse(clone.hasQueuedThreads()); |
490 |
< |
} catch (InterruptedException e) { threadUnexpectedException(e); } |
490 |
> |
} |
491 |
|
} |
492 |
|
|
493 |
|
/** |
595 |
|
s.acquire(3); |
596 |
|
}}); |
597 |
|
|
598 |
< |
waitForQueuedThreads(s); |
598 |
> |
waitForQueuedThread(s, t1); |
599 |
|
|
600 |
|
Thread t2 = newStartedThread(new CheckedRunnable() { |
601 |
|
public void realRun() throws InterruptedException { |