ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/jsr166/jsr166/src/test/tck/SemaphoreTest.java
(Generate patch)

Comparing jsr166/src/test/tck/SemaphoreTest.java (file contents):
Revision 1.11 by dl, Sun Jan 4 00:57:21 2004 UTC vs.
Revision 1.12 by dl, Sun Jan 4 22:58:03 2004 UTC

# Line 638 | Line 638 | public class SemaphoreTest extends JSR16
638          }
639      }
640  
641 +    /**
642 +     * release(n) in one thread enables acquire(n) in another thread
643 +     */
644 +    public void testAcquireReleaseNInDifferentThreads_fair2() {
645 +        final Semaphore s = new Semaphore(0, true);
646 +        Thread t = new Thread(new Runnable() {
647 +                public void run() {
648 +                    try {
649 +                        s.acquire(2);
650 +                        s.acquire(2);
651 +                        s.release(4);
652 +                    } catch(InterruptedException ie){
653 +                        threadUnexpectedException();
654 +                    }
655 +                }
656 +            });
657 +        try {
658 +            t.start();
659 +            Thread.sleep(SHORT_DELAY_MS);
660 +            s.release(6);
661 +            s.acquire(2);
662 +            s.acquire(2);
663 +            s.release(2);
664 +            t.join();
665 +        } catch( InterruptedException e){
666 +            unexpectedException();
667 +        }
668 +    }
669 +
670 +
671 +
672  
673  
674      /**

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines