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

Comparing jsr166/src/test/tck/LockSupportTest.java (file contents):
Revision 1.11 by jsr166, Tue Nov 17 12:46:10 2009 UTC vs.
Revision 1.13 by jsr166, Mon Nov 30 08:31:09 2009 UTC

# Line 13 | Line 13 | import java.util.concurrent.locks.*;
13  
14   public class LockSupportTest extends JSR166TestCase {
15      public static void main(String[] args) {
16 <        junit.textui.TestRunner.run (suite());
16 >        junit.textui.TestRunner.run (suite());
17      }
18      public static Test suite() {
19 <        return new TestSuite(LockSupportTest.class);
19 >        return new TestSuite(LockSupportTest.class);
20      }
21  
22      /**
23       * park is released by unpark occurring after park
24       */
25      public void testPark() throws InterruptedException {
26 <        Thread t = new Thread(new CheckedRunnable() {
27 <            public void realRun() {
26 >        Thread t = new Thread(new CheckedRunnable() {
27 >            public void realRun() {
28                  LockSupport.park();
29              }});
30  
# Line 38 | Line 38 | public class LockSupportTest extends JSR
38       * park is released by unpark occurring before park
39       */
40      public void testPark2() throws InterruptedException {
41 <        Thread t = new Thread(new CheckedRunnable() {
42 <            public void realRun() throws InterruptedException {
41 >        Thread t = new Thread(new CheckedRunnable() {
42 >            public void realRun() throws InterruptedException {
43                  Thread.sleep(SHORT_DELAY_MS);
44                  LockSupport.park();
45              }});
# Line 53 | Line 53 | public class LockSupportTest extends JSR
53       * park is released by interrupt
54       */
55      public void testPark3() throws InterruptedException {
56 <        Thread t = new Thread(new CheckedRunnable() {
57 <            public void realRun() {
56 >        Thread t = new Thread(new CheckedRunnable() {
57 >            public void realRun() {
58                  LockSupport.park();
59              }});
60  
# Line 70 | Line 70 | public class LockSupportTest extends JSR
70      public void testPark4() throws InterruptedException {
71          final ReentrantLock lock = new ReentrantLock();
72          lock.lock();
73 <        Thread t = new Thread(new CheckedRunnable() {
74 <            public void realRun() {
73 >        Thread t = new Thread(new CheckedRunnable() {
74 >            public void realRun() {
75                  lock.lock();
76                  LockSupport.park();
77              }});
78  
79          t.start();
80 +        Thread.sleep(SHORT_DELAY_MS);
81          t.interrupt();
82          lock.unlock();
83          t.join();
# Line 86 | Line 87 | public class LockSupportTest extends JSR
87       * parkNanos times out if not unparked
88       */
89      public void testParkNanos() throws InterruptedException {
90 <        Thread t = new Thread(new CheckedRunnable() {
91 <            public void realRun() {
90 >        Thread t = new Thread(new CheckedRunnable() {
91 >            public void realRun() {
92                  LockSupport.parkNanos(1000);
93              }});
94  
# Line 100 | Line 101 | public class LockSupportTest extends JSR
101       * parkUntil times out if not unparked
102       */
103      public void testParkUntil() throws InterruptedException {
104 <        Thread t = new Thread(new CheckedRunnable() {
105 <            public void realRun() {
104 >        Thread t = new Thread(new CheckedRunnable() {
105 >            public void realRun() {
106                  long d = new Date().getTime() + 100;
107                  LockSupport.parkUntil(d);
108              }});

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines