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

Comparing jsr166/src/test/tck/StampedLockTest.java (file contents):
Revision 1.6 by dl, Thu Mar 21 19:06:54 2013 UTC vs.
Revision 1.9 by jsr166, Wed Dec 31 16:44:02 2014 UTC

# Line 6 | Line 6
6   */
7  
8   import junit.framework.*;
9 import java.util.concurrent.atomic.AtomicBoolean;
9   import java.util.concurrent.locks.Lock;
10   import java.util.concurrent.locks.StampedLock;
11   import java.util.concurrent.CountDownLatch;
# Line 270 | Line 269 | public class StampedLockTest extends JSR
269              assertTrue((s = lock.writeLock()) != 0L);
270              assertTrue(lock.validate(s));
271              assertFalse(lock.validate(lock.tryWriteLock()));
272 <            assertFalse(lock.validate(lock.tryWriteLock(100L, MILLISECONDS)));
272 >            assertFalse(lock.validate(lock.tryWriteLock(10L, MILLISECONDS)));
273              assertFalse(lock.validate(lock.tryReadLock()));
274 <            assertFalse(lock.validate(lock.tryReadLock(100L, MILLISECONDS)));
274 >            assertFalse(lock.validate(lock.tryReadLock(10L, MILLISECONDS)));
275              assertFalse(lock.validate(lock.tryOptimisticRead()));
276              lock.unlockWrite(s);
277          } catch (InterruptedException ie) {
# Line 292 | Line 291 | public class StampedLockTest extends JSR
291                  running.countDown();
292                  lock.writeLockInterruptibly();
293              }});
294 <        try {
295 <            running.await();
294 >        try {
295 >            running.await();
296              waitForThreadToEnterWaitState(t, 100);
297              t.interrupt();
298              awaitTermination(t);
# Line 315 | Line 314 | public class StampedLockTest extends JSR
314                  running.countDown();
315                  lock.tryWriteLock(2 * LONG_DELAY_MS, MILLISECONDS);
316              }});
317 <        try {
317 >        try {
318              running.await();
319              waitForThreadToEnterWaitState(t, 100);
320              t.interrupt();
# Line 338 | Line 337 | public class StampedLockTest extends JSR
337                  running.countDown();
338                  lock.readLockInterruptibly();
339              }});
340 <        try {
341 <            running.await();
340 >        try {
341 >            running.await();
342              waitForThreadToEnterWaitState(t, 100);
343              t.interrupt();
344              awaitTermination(t);
# Line 361 | Line 360 | public class StampedLockTest extends JSR
360                  running.countDown();
361                  lock.tryReadLock(2 * LONG_DELAY_MS, MILLISECONDS);
362              }});
363 <        try {
364 <            running.await();
363 >        try {
364 >            running.await();
365              waitForThreadToEnterWaitState(t, 100);
366              t.interrupt();
367              awaitTermination(t);
# Line 452 | Line 451 | public class StampedLockTest extends JSR
451                  long s = lock.writeLock();
452                  lock.unlockWrite(s);
453              }});
454 <        try {
455 <            running.await();
454 >        try {
455 >            running.await();
456              waitForThreadToEnterWaitState(t, 100);
457              assertFalse(lock.isWriteLocked());
458              lock.unlockRead(rs);
# Line 576 | Line 575 | public class StampedLockTest extends JSR
575                  assertEquals(rs, 0L);
576                  assertTrue(millisElapsedSince(startTime) >= timeoutMillis);
577              }});
578 <        
578 >
579          awaitTermination(t);
580          assertTrue(lock.isWriteLocked());
581          lock.unlockWrite(s);
# Line 600 | Line 599 | public class StampedLockTest extends JSR
599                  lock.writeLockInterruptibly();
600              }});
601  
602 <        try {
603 <            running.await();
602 >        try {
603 >            running.await();
604              waitForThreadToEnterWaitState(t, 100);
605              t.interrupt();
606              assertTrue(lock.isWriteLocked());
# Line 632 | Line 631 | public class StampedLockTest extends JSR
631                  running.countDown();
632                  lock.readLockInterruptibly();
633              }});
634 <        try {
634 >        try {
635              running.await();
636              waitForThreadToEnterWaitState(t, 100);
637              t.interrupt();
# Line 743 | Line 742 | public class StampedLockTest extends JSR
742                      running.countDown();
743                      lock.writeLockInterruptibly();
744                  }});
745 <        try {
745 >        try {
746              running.await();
747              assertFalse(lock.validate(p));
748              assertFalse((p = lock.tryOptimisticRead()) != 0L);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines