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

Comparing jsr166/src/test/tck/ReentrantLockTest.java (file contents):
Revision 1.64 by jsr166, Sun Jan 1 20:34:39 2017 UTC vs.
Revision 1.66 by jsr166, Mon Jul 17 21:01:30 2017 UTC

# Line 20 | Line 20 | import junit.framework.AssertionFailedEr
20   import junit.framework.Test;
21   import junit.framework.TestSuite;
22  
23 + @SuppressWarnings("WaitNotInLoop") // we implement spurious-wakeup freedom
24   public class ReentrantLockTest extends JSR166TestCase {
25      public static void main(String[] args) {
26          main(suite(), args);
# Line 885 | Line 886 | public class ReentrantLockTest extends J
886      public void testAwaitUninterruptibly_fair() { testAwaitUninterruptibly(true); }
887      public void testAwaitUninterruptibly(boolean fair) {
888          final ReentrantLock lock = new ReentrantLock(fair);
889 <        final Condition c = lock.newCondition();
889 >        final Condition condition = lock.newCondition();
890          final CountDownLatch pleaseInterrupt = new CountDownLatch(2);
891  
892          Thread t1 = newStartedThread(new CheckedRunnable() {
# Line 894 | Line 895 | public class ReentrantLockTest extends J
895                  lock.lock();
896                  pleaseInterrupt.countDown();
897                  Thread.currentThread().interrupt();
898 <                c.awaitUninterruptibly();
898 >                condition.awaitUninterruptibly();
899                  assertTrue(Thread.interrupted());
900                  lock.unlock();
901              }});
# Line 904 | Line 905 | public class ReentrantLockTest extends J
905                  // Interrupt during awaitUninterruptibly
906                  lock.lock();
907                  pleaseInterrupt.countDown();
908 <                c.awaitUninterruptibly();
908 >                condition.awaitUninterruptibly();
909                  assertTrue(Thread.interrupted());
910                  lock.unlock();
911              }});
912  
913          await(pleaseInterrupt);
914 +        t2.interrupt();
915          lock.lock();
916          lock.unlock();
917 <        t2.interrupt();
918 <
917 <        assertThreadStaysAlive(t1);
918 <        assertTrue(t2.isAlive());
917 >        assertThreadBlocks(t1, Thread.State.WAITING);
918 >        assertThreadBlocks(t2, Thread.State.WAITING);
919  
920          lock.lock();
921 <        c.signalAll();
921 >        condition.signalAll();
922          lock.unlock();
923  
924          awaitTermination(t1);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines