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

Comparing jsr166/src/test/tck/AbstractQueuedSynchronizerTest.java (file contents):
Revision 1.29 by jsr166, Sat Nov 21 02:07:26 2009 UTC vs.
Revision 1.34 by jsr166, Wed Aug 25 00:07:02 2010 UTC

# Line 10 | Line 10
10   import junit.framework.*;
11   import java.util.*;
12   import java.util.concurrent.*;
13 + import static java.util.concurrent.TimeUnit.MILLISECONDS;
14   import java.util.concurrent.locks.*;
15   import java.io.*;
16  
17   public class AbstractQueuedSynchronizerTest extends JSR166TestCase {
18      public static void main(String[] args) {
19 <        junit.textui.TestRunner.run (suite());
19 >        junit.textui.TestRunner.run(suite());
20      }
21      public static Test suite() {
22          return new TestSuite(AbstractQueuedSynchronizerTest.class);
# Line 326 | Line 327 | public class AbstractQueuedSynchronizerT
327          sync.acquire(1);
328          Thread t = new Thread(new CheckedInterruptedRunnable() {
329              public void realRun() throws InterruptedException {
330 <                sync.tryAcquireNanos(1, MEDIUM_DELAY_MS * 1000 * 1000);
330 >                sync.tryAcquireNanos(1, MILLISECONDS.toNanos(MEDIUM_DELAY_MS));
331              }});
332  
333          t.start();
334 +        Thread.sleep(SHORT_DELAY_MS);
335          t.interrupt();
336          t.join();
337      }
# Line 359 | Line 361 | public class AbstractQueuedSynchronizerT
361          sync.acquire(1);
362          Thread t = new Thread(new CheckedRunnable() {
363              public void realRun() throws InterruptedException {
364 <                threadAssertFalse(sync.tryAcquireNanos(1, 1000 * 1000));
364 >                long nanos = MILLISECONDS.toNanos(SHORT_DELAY_MS);
365 >                assertFalse(sync.tryAcquireNanos(1, nanos));
366              }});
367  
368          t.start();
# Line 416 | Line 419 | public class AbstractQueuedSynchronizerT
419          sync.acquireInterruptibly(1);
420          Thread t = new Thread(new InterruptedSyncRunnable(sync));
421          t.start();
422 +        Thread.sleep(SHORT_DELAY_MS);
423          t.interrupt();
424          assertTrue(sync.isHeldExclusively());
425          t.join();
# Line 475 | Line 479 | public class AbstractQueuedSynchronizerT
479          final Mutex sync = new Mutex();
480          final AbstractQueuedSynchronizer.ConditionObject c = sync.newCondition();
481          sync.acquire(1);
482 <        assertFalse(c.await(SHORT_DELAY_MS, TimeUnit.MILLISECONDS));
482 >        assertFalse(c.await(SHORT_DELAY_MS, MILLISECONDS));
483          sync.release(1);
484      }
485  
# Line 785 | Line 789 | public class AbstractQueuedSynchronizerT
789              public void realRun() throws InterruptedException {
790                  sync.acquire(1);
791                  c.await();
788                sync.release(1);
792              }});
793  
794          t.start();
# Line 804 | Line 807 | public class AbstractQueuedSynchronizerT
807          Thread t = new Thread(new CheckedInterruptedRunnable() {
808              public void realRun() throws InterruptedException {
809                  sync.acquire(1);
810 <                c.awaitNanos(1000 * 1000 * 1000); // 1 sec
808 <                sync.release(1);
810 >                c.awaitNanos(MILLISECONDS.toNanos(LONG_DELAY_MS));
811              }});
812  
813          t.start();
# Line 826 | Line 828 | public class AbstractQueuedSynchronizerT
828                  sync.acquire(1);
829                  java.util.Date d = new java.util.Date();
830                  c.awaitUntil(new java.util.Date(d.getTime() + 10000));
829                sync.release(1);
831              }});
832  
833          t.start();
# Line 953 | Line 954 | public class AbstractQueuedSynchronizerT
954  
955          Thread t = new Thread(new CheckedRunnable() {
956              public void realRun() throws InterruptedException {
957 <                threadAssertFalse(l.isSignalled());
958 <                threadAssertTrue(l.tryAcquireSharedNanos(0, MEDIUM_DELAY_MS* 1000 * 1000));
959 <                threadAssertTrue(l.isSignalled());
957 >                assertFalse(l.isSignalled());
958 >                long nanos = MILLISECONDS.toNanos(MEDIUM_DELAY_MS);
959 >                assertTrue(l.tryAcquireSharedNanos(0, nanos));
960 >                assertTrue(l.isSignalled());
961              }});
962  
963          t.start();
# Line 990 | Line 992 | public class AbstractQueuedSynchronizerT
992          final BooleanLatch l = new BooleanLatch();
993          Thread t = new Thread(new CheckedInterruptedRunnable() {
994              public void realRun() throws InterruptedException {
995 <                threadAssertFalse(l.isSignalled());
996 <                l.tryAcquireSharedNanos(0, SMALL_DELAY_MS* 1000 * 1000);
995 >                assertFalse(l.isSignalled());
996 >                long nanos = MILLISECONDS.toNanos(SMALL_DELAY_MS);
997 >                l.tryAcquireSharedNanos(0, nanos);
998              }});
999  
1000          t.start();
# Line 1008 | Line 1011 | public class AbstractQueuedSynchronizerT
1011          final BooleanLatch l = new BooleanLatch();
1012          Thread t = new Thread(new CheckedRunnable() {
1013              public void realRun() throws InterruptedException {
1014 <                threadAssertFalse(l.isSignalled());
1015 <                threadAssertFalse(l.tryAcquireSharedNanos(0, SMALL_DELAY_MS* 1000 * 1000));
1014 >                assertFalse(l.isSignalled());
1015 >                long nanos = MILLISECONDS.toNanos(SMALL_DELAY_MS);
1016 >                assertFalse(l.tryAcquireSharedNanos(0, nanos));
1017              }});
1018  
1019          t.start();

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines