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.29 by jsr166, Tue Nov 17 13:31:53 2009 UTC vs.
Revision 1.37 by jsr166, Thu Sep 16 00:52:49 2010 UTC

# Line 9 | Line 9
9   import junit.framework.*;
10   import java.util.concurrent.locks.*;
11   import java.util.concurrent.*;
12 + import static java.util.concurrent.TimeUnit.MILLISECONDS;
13   import java.util.*;
14   import java.io.*;
15  
16   public class ReentrantLockTest extends JSR166TestCase {
17      public static void main(String[] args) {
18 <        junit.textui.TestRunner.run (suite());
18 >        junit.textui.TestRunner.run(suite());
19      }
20      public static Test suite() {
21 <        return new TestSuite(ReentrantLockTest.class);
21 >        return new TestSuite(ReentrantLockTest.class);
22      }
23  
24      /**
# Line 55 | Line 56 | public class ReentrantLockTest extends J
56          public Collection<Thread> getWaitingThreads(Condition c) {
57              return super.getWaitingThreads(c);
58          }
58
59
59      }
60  
61      /**
# Line 72 | Line 71 | public class ReentrantLockTest extends J
71       * locking an unlocked lock succeeds
72       */
73      public void testLock() {
74 <        ReentrantLock rl = new ReentrantLock();
74 >        ReentrantLock rl = new ReentrantLock();
75          rl.lock();
76          assertTrue(rl.isLocked());
77          rl.unlock();
# Line 83 | Line 82 | public class ReentrantLockTest extends J
82       * locking an unlocked fair lock succeeds
83       */
84      public void testFairLock() {
85 <        ReentrantLock rl = new ReentrantLock(true);
85 >        ReentrantLock rl = new ReentrantLock(true);
86          rl.lock();
87          assertTrue(rl.isLocked());
88          rl.unlock();
# Line 93 | Line 92 | public class ReentrantLockTest extends J
92       * Unlocking an unlocked lock throws IllegalMonitorStateException
93       */
94      public void testUnlock_IllegalMonitorStateException() {
95 <        ReentrantLock rl = new ReentrantLock();
96 <        try {
97 <            rl.unlock();
98 <            shouldThrow();
99 <        } catch (IllegalMonitorStateException success) {}
95 >        ReentrantLock rl = new ReentrantLock();
96 >        try {
97 >            rl.unlock();
98 >            shouldThrow();
99 >        } catch (IllegalMonitorStateException success) {}
100      }
101  
102      /**
103       * tryLock on an unlocked lock succeeds
104       */
105      public void testTryLock() {
106 <        ReentrantLock rl = new ReentrantLock();
106 >        ReentrantLock rl = new ReentrantLock();
107          assertTrue(rl.tryLock());
108          assertTrue(rl.isLocked());
109          rl.unlock();
# Line 115 | Line 114 | public class ReentrantLockTest extends J
114       * hasQueuedThreads reports whether there are waiting threads
115       */
116      public void testhasQueuedThreads() throws InterruptedException {
117 <        final ReentrantLock lock = new ReentrantLock();
117 >        final ReentrantLock lock = new ReentrantLock();
118          Thread t1 = new Thread(new InterruptedLockRunnable(lock));
119          Thread t2 = new Thread(new InterruptibleLockRunnable(lock));
120          assertFalse(lock.hasQueuedThreads());
# Line 140 | Line 139 | public class ReentrantLockTest extends J
139       * getQueueLength reports number of waiting threads
140       */
141      public void testGetQueueLength() throws InterruptedException {
142 <        final ReentrantLock lock = new ReentrantLock();
142 >        final ReentrantLock lock = new ReentrantLock();
143          Thread t1 = new Thread(new InterruptedLockRunnable(lock));
144          Thread t2 = new Thread(new InterruptibleLockRunnable(lock));
145          assertEquals(0, lock.getQueueLength());
# Line 165 | Line 164 | public class ReentrantLockTest extends J
164       * getQueueLength reports number of waiting threads
165       */
166      public void testGetQueueLength_fair() throws InterruptedException {
167 <        final ReentrantLock lock = new ReentrantLock(true);
167 >        final ReentrantLock lock = new ReentrantLock(true);
168          Thread t1 = new Thread(new InterruptedLockRunnable(lock));
169          Thread t2 = new Thread(new InterruptibleLockRunnable(lock));
170          assertEquals(0, lock.getQueueLength());
# Line 190 | Line 189 | public class ReentrantLockTest extends J
189       * hasQueuedThread(null) throws NPE
190       */
191      public void testHasQueuedThreadNPE() {
192 <        final ReentrantLock sync = new ReentrantLock();
192 >        final ReentrantLock sync = new ReentrantLock();
193          try {
194              sync.hasQueuedThread(null);
195              shouldThrow();
# Line 201 | Line 200 | public class ReentrantLockTest extends J
200       * hasQueuedThread reports whether a thread is queued.
201       */
202      public void testHasQueuedThread() throws InterruptedException {
203 <        final ReentrantLock sync = new ReentrantLock();
203 >        final ReentrantLock sync = new ReentrantLock();
204          Thread t1 = new Thread(new InterruptedLockRunnable(sync));
205          Thread t2 = new Thread(new InterruptibleLockRunnable(sync));
206          assertFalse(sync.hasQueuedThread(t1));
# Line 232 | Line 231 | public class ReentrantLockTest extends J
231       * getQueuedThreads includes waiting threads
232       */
233      public void testGetQueuedThreads() throws InterruptedException {
234 <        final PublicReentrantLock lock = new PublicReentrantLock();
234 >        final PublicReentrantLock lock = new PublicReentrantLock();
235          Thread t1 = new Thread(new InterruptedLockRunnable(lock));
236          Thread t2 = new Thread(new InterruptibleLockRunnable(lock));
237          assertTrue(lock.getQueuedThreads().isEmpty());
# Line 261 | Line 260 | public class ReentrantLockTest extends J
260       * timed tryLock is interruptible.
261       */
262      public void testInterruptedException2() throws InterruptedException {
263 <        final ReentrantLock lock = new ReentrantLock();
264 <        lock.lock();
265 <        Thread t = new Thread(new CheckedInterruptedRunnable() {
263 >        final ReentrantLock lock = new ReentrantLock();
264 >        lock.lock();
265 >        Thread t = new Thread(new CheckedInterruptedRunnable() {
266              public void realRun() throws InterruptedException {
267 <                lock.tryLock(MEDIUM_DELAY_MS,TimeUnit.MILLISECONDS);
267 >                lock.tryLock(MEDIUM_DELAY_MS,MILLISECONDS);
268              }});
269  
270          t.start();
271 +        Thread.sleep(SHORT_DELAY_MS);
272          t.interrupt();
273          t.join();
274      }
# Line 278 | Line 278 | public class ReentrantLockTest extends J
278       * TryLock on a locked lock fails
279       */
280      public void testTryLockWhenLocked() throws InterruptedException {
281 <        final ReentrantLock lock = new ReentrantLock();
282 <        lock.lock();
283 <        Thread t = new Thread(new CheckedRunnable() {
281 >        final ReentrantLock lock = new ReentrantLock();
282 >        lock.lock();
283 >        Thread t = new Thread(new CheckedRunnable() {
284              public void realRun() {
285 <                threadAssertFalse(lock.tryLock());
285 >                assertFalse(lock.tryLock());
286              }});
287  
288          t.start();
# Line 294 | Line 294 | public class ReentrantLockTest extends J
294       * Timed tryLock on a locked lock times out
295       */
296      public void testTryLock_Timeout() throws InterruptedException {
297 <        final ReentrantLock lock = new ReentrantLock();
298 <        lock.lock();
299 <        Thread t = new Thread(new CheckedRunnable() {
297 >        final ReentrantLock lock = new ReentrantLock();
298 >        lock.lock();
299 >        Thread t = new Thread(new CheckedRunnable() {
300              public void realRun() throws InterruptedException {
301 <                threadAssertFalse(lock.tryLock(1, TimeUnit.MILLISECONDS));
301 >                assertFalse(lock.tryLock(1, MILLISECONDS));
302              }});
303  
304          t.start();
# Line 310 | Line 310 | public class ReentrantLockTest extends J
310       * getHoldCount returns number of recursive holds
311       */
312      public void testGetHoldCount() {
313 <        ReentrantLock lock = new ReentrantLock();
314 <        for (int i = 1; i <= SIZE; i++) {
315 <            lock.lock();
316 <            assertEquals(i, lock.getHoldCount());
317 <        }
318 <        for (int i = SIZE; i > 0; i--) {
319 <            lock.unlock();
320 <            assertEquals(i-1, lock.getHoldCount());
321 <        }
313 >        ReentrantLock lock = new ReentrantLock();
314 >        for (int i = 1; i <= SIZE; i++) {
315 >            lock.lock();
316 >            assertEquals(i, lock.getHoldCount());
317 >        }
318 >        for (int i = SIZE; i > 0; i--) {
319 >            lock.unlock();
320 >            assertEquals(i-1, lock.getHoldCount());
321 >        }
322      }
323  
324  
# Line 326 | Line 326 | public class ReentrantLockTest extends J
326       * isLocked is true when locked and false when not
327       */
328      public void testIsLocked() throws InterruptedException {
329 <        final ReentrantLock lock = new ReentrantLock();
330 <        lock.lock();
331 <        assertTrue(lock.isLocked());
332 <        lock.unlock();
333 <        assertFalse(lock.isLocked());
334 <        Thread t = new Thread(new CheckedRunnable() {
329 >        final ReentrantLock lock = new ReentrantLock();
330 >        lock.lock();
331 >        assertTrue(lock.isLocked());
332 >        lock.unlock();
333 >        assertFalse(lock.isLocked());
334 >        Thread t = new Thread(new CheckedRunnable() {
335              public void realRun() throws InterruptedException {
336                  lock.lock();
337                  Thread.sleep(SMALL_DELAY_MS);
# Line 350 | Line 350 | public class ReentrantLockTest extends J
350       * lockInterruptibly is interruptible.
351       */
352      public void testLockInterruptibly1() throws InterruptedException {
353 <        final ReentrantLock lock = new ReentrantLock();
354 <        lock.lock();
355 <        Thread t = new Thread(new InterruptedLockRunnable(lock));
353 >        final ReentrantLock lock = new ReentrantLock();
354 >        lock.lock();
355 >        Thread t = new Thread(new InterruptedLockRunnable(lock));
356          t.start();
357          Thread.sleep(SHORT_DELAY_MS);
358          t.interrupt();
# Line 365 | Line 365 | public class ReentrantLockTest extends J
365       * lockInterruptibly succeeds when unlocked, else is interruptible
366       */
367      public void testLockInterruptibly2() throws InterruptedException {
368 <        final ReentrantLock lock = new ReentrantLock();
368 >        final ReentrantLock lock = new ReentrantLock();
369          lock.lockInterruptibly();
370 <        Thread t = new Thread(new InterruptedLockRunnable(lock));
370 >        Thread t = new Thread(new InterruptedLockRunnable(lock));
371          t.start();
372 +        Thread.sleep(SHORT_DELAY_MS);
373          t.interrupt();
374          assertTrue(lock.isLocked());
375          assertTrue(lock.isHeldByCurrentThread());
# Line 379 | Line 380 | public class ReentrantLockTest extends J
380       * Calling await without holding lock throws IllegalMonitorStateException
381       */
382      public void testAwait_IllegalMonitor() throws InterruptedException {
383 <        final ReentrantLock lock = new ReentrantLock();
383 >        final ReentrantLock lock = new ReentrantLock();
384          final Condition c = lock.newCondition();
385          try {
386              c.await();
# Line 391 | Line 392 | public class ReentrantLockTest extends J
392       * Calling signal without holding lock throws IllegalMonitorStateException
393       */
394      public void testSignal_IllegalMonitor() {
395 <        final ReentrantLock lock = new ReentrantLock();
395 >        final ReentrantLock lock = new ReentrantLock();
396          final Condition c = lock.newCondition();
397          try {
398              c.signal();
# Line 403 | Line 404 | public class ReentrantLockTest extends J
404       * awaitNanos without a signal times out
405       */
406      public void testAwaitNanos_Timeout() throws InterruptedException {
407 <        final ReentrantLock lock = new ReentrantLock();
407 >        final ReentrantLock lock = new ReentrantLock();
408          final Condition c = lock.newCondition();
409          lock.lock();
410          long t = c.awaitNanos(100);
# Line 415 | Line 416 | public class ReentrantLockTest extends J
416       *  timed await without a signal times out
417       */
418      public void testAwait_Timeout() throws InterruptedException {
419 <        final ReentrantLock lock = new ReentrantLock();
419 >        final ReentrantLock lock = new ReentrantLock();
420          final Condition c = lock.newCondition();
421          lock.lock();
422 <        assertFalse(c.await(SHORT_DELAY_MS, TimeUnit.MILLISECONDS));
422 >        assertFalse(c.await(SHORT_DELAY_MS, MILLISECONDS));
423          lock.unlock();
424      }
425  
# Line 426 | Line 427 | public class ReentrantLockTest extends J
427       * awaitUntil without a signal times out
428       */
429      public void testAwaitUntil_Timeout() throws InterruptedException {
430 <        final ReentrantLock lock = new ReentrantLock();
430 >        final ReentrantLock lock = new ReentrantLock();
431          final Condition c = lock.newCondition();
432          lock.lock();
433          java.util.Date d = new java.util.Date();
# Line 438 | Line 439 | public class ReentrantLockTest extends J
439       * await returns when signalled
440       */
441      public void testAwait() throws InterruptedException {
442 <        final ReentrantLock lock = new ReentrantLock();
442 >        final ReentrantLock lock = new ReentrantLock();
443          final Condition c = lock.newCondition();
444 <        Thread t = new Thread(new CheckedRunnable() {
444 >        Thread t = new Thread(new CheckedRunnable() {
445              public void realRun() throws InterruptedException {
446                  lock.lock();
447                  c.await();
# Line 460 | Line 461 | public class ReentrantLockTest extends J
461       * hasWaiters throws NPE if null
462       */
463      public void testHasWaitersNPE() {
464 <        final ReentrantLock lock = new ReentrantLock();
464 >        final ReentrantLock lock = new ReentrantLock();
465          try {
466              lock.hasWaiters(null);
467              shouldThrow();
# Line 471 | Line 472 | public class ReentrantLockTest extends J
472       * getWaitQueueLength throws NPE if null
473       */
474      public void testGetWaitQueueLengthNPE() {
475 <        final ReentrantLock lock = new ReentrantLock();
475 >        final ReentrantLock lock = new ReentrantLock();
476          try {
477              lock.getWaitQueueLength(null);
478              shouldThrow();
# Line 483 | Line 484 | public class ReentrantLockTest extends J
484       * getWaitingThreads throws NPE if null
485       */
486      public void testGetWaitingThreadsNPE() {
487 <        final PublicReentrantLock lock = new PublicReentrantLock();
487 >        final PublicReentrantLock lock = new PublicReentrantLock();
488          try {
489              lock.getWaitingThreads(null);
490              shouldThrow();
# Line 495 | Line 496 | public class ReentrantLockTest extends J
496       * hasWaiters throws IAE if not owned
497       */
498      public void testHasWaitersIAE() {
499 <        final ReentrantLock lock = new ReentrantLock();
499 >        final ReentrantLock lock = new ReentrantLock();
500          final Condition c = lock.newCondition();
501 <        final ReentrantLock lock2 = new ReentrantLock();
501 >        final ReentrantLock lock2 = new ReentrantLock();
502          try {
503              lock2.hasWaiters(c);
504              shouldThrow();
# Line 508 | Line 509 | public class ReentrantLockTest extends J
509       * hasWaiters throws IMSE if not locked
510       */
511      public void testHasWaitersIMSE() {
512 <        final ReentrantLock lock = new ReentrantLock();
512 >        final ReentrantLock lock = new ReentrantLock();
513          final Condition c = lock.newCondition();
514          try {
515              lock.hasWaiters(c);
# Line 521 | Line 522 | public class ReentrantLockTest extends J
522       * getWaitQueueLength throws IAE if not owned
523       */
524      public void testGetWaitQueueLengthIAE() {
525 <        final ReentrantLock lock = new ReentrantLock();
525 >        final ReentrantLock lock = new ReentrantLock();
526          final Condition c = lock.newCondition();
527 <        final ReentrantLock lock2 = new ReentrantLock();
527 >        final ReentrantLock lock2 = new ReentrantLock();
528          try {
529              lock2.getWaitQueueLength(c);
530              shouldThrow();
# Line 534 | Line 535 | public class ReentrantLockTest extends J
535       * getWaitQueueLength throws IMSE if not locked
536       */
537      public void testGetWaitQueueLengthIMSE() {
538 <        final ReentrantLock lock = new ReentrantLock();
538 >        final ReentrantLock lock = new ReentrantLock();
539          final Condition c = lock.newCondition();
540          try {
541              lock.getWaitQueueLength(c);
# Line 547 | Line 548 | public class ReentrantLockTest extends J
548       * getWaitingThreads throws IAE if not owned
549       */
550      public void testGetWaitingThreadsIAE() {
551 <        final PublicReentrantLock lock = new PublicReentrantLock();
551 >        final PublicReentrantLock lock = new PublicReentrantLock();
552          final Condition c = lock.newCondition();
553 <        final PublicReentrantLock lock2 = new PublicReentrantLock();
553 >        final PublicReentrantLock lock2 = new PublicReentrantLock();
554          try {
555              lock2.getWaitingThreads(c);
556              shouldThrow();
# Line 560 | Line 561 | public class ReentrantLockTest extends J
561       * getWaitingThreads throws IMSE if not locked
562       */
563      public void testGetWaitingThreadsIMSE() {
564 <        final PublicReentrantLock lock = new PublicReentrantLock();
564 >        final PublicReentrantLock lock = new PublicReentrantLock();
565          final Condition c = lock.newCondition();
566          try {
567              lock.getWaitingThreads(c);
# Line 573 | Line 574 | public class ReentrantLockTest extends J
574       * hasWaiters returns true when a thread is waiting, else false
575       */
576      public void testHasWaiters() throws InterruptedException {
577 <        final ReentrantLock lock = new ReentrantLock();
577 >        final ReentrantLock lock = new ReentrantLock();
578          final Condition c = lock.newCondition();
579 <        Thread t = new Thread(new CheckedRunnable() {
579 >        Thread t = new Thread(new CheckedRunnable() {
580              public void realRun() throws InterruptedException {
581                  lock.lock();
582 <                threadAssertFalse(lock.hasWaiters(c));
583 <                threadAssertEquals(0, lock.getWaitQueueLength(c));
582 >                assertFalse(lock.hasWaiters(c));
583 >                assertEquals(0, lock.getWaitQueueLength(c));
584                  c.await();
585                  lock.unlock();
586              }});
# Line 604 | Line 605 | public class ReentrantLockTest extends J
605       * getWaitQueueLength returns number of waiting threads
606       */
607      public void testGetWaitQueueLength() throws InterruptedException {
608 <        final ReentrantLock lock = new ReentrantLock();
608 >        final ReentrantLock lock = new ReentrantLock();
609          final Condition c = lock.newCondition();
610 <        Thread t1 = new Thread(new CheckedRunnable() {
610 >        Thread t1 = new Thread(new CheckedRunnable() {
611              public void realRun() throws InterruptedException {
612                  lock.lock();
613 <                threadAssertFalse(lock.hasWaiters(c));
614 <                threadAssertEquals(0, lock.getWaitQueueLength(c));
613 >                assertFalse(lock.hasWaiters(c));
614 >                assertEquals(0, lock.getWaitQueueLength(c));
615                  c.await();
616                  lock.unlock();
617              }});
618  
619 <        Thread t2 = new Thread(new CheckedRunnable() {
619 >        Thread t2 = new Thread(new CheckedRunnable() {
620              public void realRun() throws InterruptedException {
621                  lock.lock();
622 <                threadAssertTrue(lock.hasWaiters(c));
623 <                threadAssertEquals(1, lock.getWaitQueueLength(c));
622 >                assertTrue(lock.hasWaiters(c));
623 >                assertEquals(1, lock.getWaitQueueLength(c));
624                  c.await();
625                  lock.unlock();
626              }});
# Line 648 | Line 649 | public class ReentrantLockTest extends J
649       * getWaitingThreads returns only and all waiting threads
650       */
651      public void testGetWaitingThreads() throws InterruptedException {
652 <        final PublicReentrantLock lock = new PublicReentrantLock();
652 >        final PublicReentrantLock lock = new PublicReentrantLock();
653          final Condition c = lock.newCondition();
654 <        Thread t1 = new Thread(new CheckedRunnable() {
654 >        Thread t1 = new Thread(new CheckedRunnable() {
655              public void realRun() throws InterruptedException {
656                  lock.lock();
657 <                threadAssertTrue(lock.getWaitingThreads(c).isEmpty());
657 >                assertTrue(lock.getWaitingThreads(c).isEmpty());
658                  c.await();
659                  lock.unlock();
660              }});
661  
662 <        Thread t2 = new Thread(new CheckedRunnable() {
662 >        Thread t2 = new Thread(new CheckedRunnable() {
663              public void realRun() throws InterruptedException {
664                  lock.lock();
665 <                threadAssertFalse(lock.getWaitingThreads(c).isEmpty());
665 >                assertFalse(lock.getWaitingThreads(c).isEmpty());
666                  c.await();
667                  lock.unlock();
668              }});
# Line 749 | Line 750 | public class ReentrantLockTest extends J
750       * await is interruptible
751       */
752      public void testAwait_Interrupt() throws InterruptedException {
753 <        final ReentrantLock lock = new ReentrantLock();
753 >        final ReentrantLock lock = new ReentrantLock();
754          final Condition c = lock.newCondition();
755 <        Thread t = new Thread(new CheckedInterruptedRunnable() {
756 <            public void realRun() throws InterruptedException {
755 >        Thread t = new Thread(new CheckedInterruptedRunnable() {
756 >            public void realRun() throws InterruptedException {
757                  lock.lock();
758                  c.await();
759              }});
# Line 768 | Line 769 | public class ReentrantLockTest extends J
769       * awaitNanos is interruptible
770       */
771      public void testAwaitNanos_Interrupt() throws InterruptedException {
772 <        final ReentrantLock lock = new ReentrantLock();
772 >        final ReentrantLock lock = new ReentrantLock();
773          final Condition c = lock.newCondition();
774 <        Thread t = new Thread(new CheckedInterruptedRunnable() {
775 <            public void realRun() throws InterruptedException {
774 >        Thread t = new Thread(new CheckedInterruptedRunnable() {
775 >            public void realRun() throws InterruptedException {
776                  lock.lock();
777 <                c.awaitNanos(1000 * 1000 * 1000); // 1 sec
777 >                c.awaitNanos(MILLISECONDS.toNanos(LONG_DELAY_MS));
778              }});
779  
780          t.start();
# Line 787 | Line 788 | public class ReentrantLockTest extends J
788       * awaitUntil is interruptible
789       */
790      public void testAwaitUntil_Interrupt() throws InterruptedException {
791 <        final ReentrantLock lock = new ReentrantLock();
791 >        final ReentrantLock lock = new ReentrantLock();
792          final Condition c = lock.newCondition();
793 <        Thread t = new Thread(new CheckedInterruptedRunnable() {
794 <            public void realRun() throws InterruptedException {
793 >        Thread t = new Thread(new CheckedInterruptedRunnable() {
794 >            public void realRun() throws InterruptedException {
795                  lock.lock();
796                  java.util.Date d = new java.util.Date();
797                  c.awaitUntil(new java.util.Date(d.getTime() + 10000));
# Line 807 | Line 808 | public class ReentrantLockTest extends J
808       * signalAll wakes up all threads
809       */
810      public void testSignalAll() throws InterruptedException {
811 <        final ReentrantLock lock = new ReentrantLock();
811 >        final ReentrantLock lock = new ReentrantLock();
812          final Condition c = lock.newCondition();
813 <        Thread t1 = new Thread(new CheckedRunnable() {
813 >        Thread t1 = new Thread(new CheckedRunnable() {
814              public void realRun() throws InterruptedException {
815                  lock.lock();
816                  c.await();
817                  lock.unlock();
818              }});
819  
820 <        Thread t2 = new Thread(new CheckedRunnable() {
820 >        Thread t2 = new Thread(new CheckedRunnable() {
821              public void realRun() throws InterruptedException {
822                  lock.lock();
823                  c.await();
# Line 839 | Line 840 | public class ReentrantLockTest extends J
840       * await after multiple reentrant locking preserves lock count
841       */
842      public void testAwaitLockCount() throws InterruptedException {
843 <        final ReentrantLock lock = new ReentrantLock();
843 >        final ReentrantLock lock = new ReentrantLock();
844          final Condition c = lock.newCondition();
845 <        Thread t1 = new Thread(new CheckedRunnable() {
845 >        Thread t1 = new Thread(new CheckedRunnable() {
846              public void realRun() throws InterruptedException {
847                  lock.lock();
848 <                threadAssertEquals(1, lock.getHoldCount());
848 >                assertEquals(1, lock.getHoldCount());
849                  c.await();
850 <                threadAssertEquals(1, lock.getHoldCount());
850 >                assertEquals(1, lock.getHoldCount());
851                  lock.unlock();
852              }});
853  
854 <        Thread t2 = new Thread(new CheckedRunnable() {
854 >        Thread t2 = new Thread(new CheckedRunnable() {
855              public void realRun() throws InterruptedException {
856                  lock.lock();
857                  lock.lock();
858 <                threadAssertEquals(2, lock.getHoldCount());
858 >                assertEquals(2, lock.getHoldCount());
859                  c.await();
860 <                threadAssertEquals(2, lock.getHoldCount());
860 >                assertEquals(2, lock.getHoldCount());
861                  lock.unlock();
862                  lock.unlock();
863              }});
# Line 886 | Line 887 | public class ReentrantLockTest extends J
887              new ObjectOutputStream(new BufferedOutputStream(bout));
888          out.writeObject(l);
889          out.close();
890 <        
890 >
891          ByteArrayInputStream bin =
892              new ByteArrayInputStream(bout.toByteArray());
893          ObjectInputStream in =

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines