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

Comparing jsr166/src/test/tck/ReentrantReadWriteLockTest.java (file contents):
Revision 1.27 by dl, Thu May 18 10:29:23 2006 UTC vs.
Revision 1.28 by jsr166, Mon Nov 2 20:28:31 2009 UTC

# Line 2 | Line 2
2   * Written by Doug Lea with assistance from members of JCP JSR-166
3   * Expert Group and released to the public domain, as explained at
4   * http://creativecommons.org/licenses/publicdomain
5 < * Other contributors include Andrew Wright, Jeffrey Hayes,
6 < * Pat Fisher, Mike Judd.
5 > * Other contributors include Andrew Wright, Jeffrey Hayes,
6 > * Pat Fisher, Mike Judd.
7   */
8  
9   import junit.framework.*;
# Line 14 | Line 14 | import java.util.*;
14  
15   public class ReentrantReadWriteLockTest extends JSR166TestCase {
16      public static void main(String[] args) {
17 <        junit.textui.TestRunner.run (suite());  
17 >        junit.textui.TestRunner.run (suite());
18      }
19      public static Test suite() {
20          return new TestSuite(ReentrantReadWriteLockTest.class);
# Line 54 | Line 54 | public class ReentrantReadWriteLockTest
54       */
55      static class PublicReentrantReadWriteLock extends ReentrantReadWriteLock {
56          PublicReentrantReadWriteLock() { super(); }
57 <        public Collection<Thread> getQueuedThreads() {
58 <            return super.getQueuedThreads();
57 >        public Collection<Thread> getQueuedThreads() {
58 >            return super.getQueuedThreads();
59          }
60 <        public Collection<Thread> getWaitingThreads(Condition c) {
61 <            return super.getWaitingThreads(c);
60 >        public Collection<Thread> getWaitingThreads(Condition c) {
61 >            return super.getWaitingThreads(c);
62          }
63      }
64  
65      /**
66       * Constructor sets given fairness, and is in unlocked state
67       */
68 <    public void testConstructor() {
68 >    public void testConstructor() {
69          ReentrantReadWriteLock rl = new ReentrantReadWriteLock();
70          assertFalse(rl.isFair());
71          assertFalse(rl.isWriteLocked());
# Line 79 | Line 79 | public class ReentrantReadWriteLockTest
79      /**
80       * write-locking and read-locking an unlocked lock succeed
81       */
82 <    public void testLock() {
82 >    public void testLock() {
83          ReentrantReadWriteLock rl = new ReentrantReadWriteLock();
84          rl.writeLock().lock();
85          assertTrue(rl.isWriteLocked());
# Line 105 | Line 105 | public class ReentrantReadWriteLockTest
105      /**
106       * locking an unlocked fair lock succeeds
107       */
108 <    public void testFairLock() {
108 >    public void testFairLock() {
109          ReentrantReadWriteLock rl = new ReentrantReadWriteLock(true);
110          rl.writeLock().lock();
111          assertTrue(rl.isWriteLocked());
# Line 171 | Line 171 | public class ReentrantReadWriteLockTest
171              assertEquals(i-1,lock.getReadHoldCount());
172          }
173      }
174 <    
174 >
175  
176      /**
177       * write-unlocking an unlocked lock throws IllegalMonitorStateException
178       */
179 <    public void testUnlock_IllegalMonitorStateException() {
179 >    public void testUnlock_IllegalMonitorStateException() {
180          ReentrantReadWriteLock rl = new ReentrantReadWriteLock();
181          try {
182              rl.writeLock().unlock();
# Line 188 | Line 188 | public class ReentrantReadWriteLockTest
188      /**
189       * write-lockInterruptibly is interruptible
190       */
191 <    public void testWriteLockInterruptibly_Interrupted() {
191 >    public void testWriteLockInterruptibly_Interrupted() {
192          final ReentrantReadWriteLock lock = new ReentrantReadWriteLock();
193          Thread t = new Thread(new Runnable() {
194                  public void run() {
# Line 211 | Line 211 | public class ReentrantReadWriteLockTest
211          } catch(Exception e){
212              unexpectedException();
213          }
214 <    }
214 >    }
215  
216      /**
217       * timed write-tryLock is interruptible
218       */
219 <    public void testWriteTryLock_Interrupted() {
219 >    public void testWriteTryLock_Interrupted() {
220          final ReentrantReadWriteLock lock = new ReentrantReadWriteLock();
221          lock.writeLock().lock();
222          Thread t = new Thread(new Runnable() {
# Line 239 | Line 239 | public class ReentrantReadWriteLockTest
239      /**
240       * read-lockInterruptibly is interruptible
241       */
242 <    public void testReadLockInterruptibly_Interrupted() {
242 >    public void testReadLockInterruptibly_Interrupted() {
243          final ReentrantReadWriteLock lock = new ReentrantReadWriteLock();
244          lock.writeLock().lock();
245          Thread t = new Thread(new Runnable() {
# Line 259 | Line 259 | public class ReentrantReadWriteLockTest
259          } catch(Exception e){
260              unexpectedException();
261          }
262 <    }
262 >    }
263  
264      /**
265       * timed read-tryLock is interruptible
266       */
267 <    public void testReadTryLock_Interrupted() {
267 >    public void testReadTryLock_Interrupted() {
268          final ReentrantReadWriteLock lock = new ReentrantReadWriteLock();
269          lock.writeLock().lock();
270          Thread t = new Thread(new Runnable() {
# Line 284 | Line 284 | public class ReentrantReadWriteLockTest
284          }
285      }
286  
287 <    
287 >
288      /**
289       * write-tryLock fails if locked
290       */
291 <    public void testWriteTryLockWhenLocked() {
291 >    public void testWriteTryLockWhenLocked() {
292          final ReentrantReadWriteLock lock = new ReentrantReadWriteLock();
293          lock.writeLock().lock();
294          Thread t = new Thread(new Runnable() {
# Line 303 | Line 303 | public class ReentrantReadWriteLockTest
303          } catch(Exception e){
304              unexpectedException();
305          }
306 <    }
306 >    }
307  
308      /**
309       * read-tryLock fails if locked
310       */
311 <    public void testReadTryLockWhenLocked() {
311 >    public void testReadTryLockWhenLocked() {
312          final ReentrantReadWriteLock lock = new ReentrantReadWriteLock();
313          lock.writeLock().lock();
314          Thread t = new Thread(new Runnable() {
# Line 323 | Line 323 | public class ReentrantReadWriteLockTest
323          } catch(Exception e){
324              unexpectedException();
325          }
326 <    }
326 >    }
327  
328      /**
329       * Multiple threads can hold a read lock when not write-locked
330       */
331 <    public void testMultipleReadLocks() {
331 >    public void testMultipleReadLocks() {
332          final ReentrantReadWriteLock lock = new ReentrantReadWriteLock();
333          lock.readLock().lock();
334          Thread t = new Thread(new Runnable() {
# Line 344 | Line 344 | public class ReentrantReadWriteLockTest
344          } catch(Exception e){
345              unexpectedException();
346          }
347 <    }
347 >    }
348  
349      /**
350       * A writelock succeeds after reading threads unlock
351       */
352 <    public void testWriteAfterMultipleReadLocks() {
352 >    public void testWriteAfterMultipleReadLocks() {
353          final ReentrantReadWriteLock lock = new ReentrantReadWriteLock();
354          lock.readLock().lock();
355          Thread t1 = new Thread(new Runnable() {
# Line 374 | Line 374 | public class ReentrantReadWriteLockTest
374              t2.join(MEDIUM_DELAY_MS);
375              assertTrue(!t1.isAlive());
376              assertTrue(!t2.isAlive());
377 <          
377 >
378          } catch(Exception e){
379              unexpectedException();
380          }
381 <    }
381 >    }
382  
383      /**
384       * Readlocks succeed after a writing thread unlocks
385       */
386 <    public void testReadAfterWriteLock() {
386 >    public void testReadAfterWriteLock() {
387          final ReentrantReadWriteLock lock = new ReentrantReadWriteLock();
388          lock.writeLock().lock();
389          Thread t1 = new Thread(new Runnable() {
# Line 408 | Line 408 | public class ReentrantReadWriteLockTest
408              t2.join(MEDIUM_DELAY_MS);
409              assertTrue(!t1.isAlive());
410              assertTrue(!t2.isAlive());
411 <          
411 >
412          } catch(Exception e){
413              unexpectedException();
414          }
415 <    }
415 >    }
416  
417      /**
418       * Read trylock succeeds if write locked by current thread
419       */
420 <    public void testReadHoldingWriteLock() {
420 >    public void testReadHoldingWriteLock() {
421          final ReentrantReadWriteLock lock = new ReentrantReadWriteLock();
422          lock.writeLock().lock();
423          assertTrue(lock.readLock().tryLock());
424          lock.readLock().unlock();
425          lock.writeLock().unlock();
426 <    }
426 >    }
427  
428      /**
429       * Read lock succeeds if write locked by current thread even if
430       * other threads are waiting for readlock
431       */
432 <    public void testReadHoldingWriteLock2() {
432 >    public void testReadHoldingWriteLock2() {
433          final ReentrantReadWriteLock lock = new ReentrantReadWriteLock();
434          lock.writeLock().lock();
435          Thread t1 = new Thread(new Runnable() {
# Line 458 | Line 458 | public class ReentrantReadWriteLockTest
458              t2.join(MEDIUM_DELAY_MS);
459              assertTrue(!t1.isAlive());
460              assertTrue(!t2.isAlive());
461 <          
461 >
462          } catch(Exception e){
463              unexpectedException();
464          }
465 <    }
465 >    }
466  
467      /**
468       *  Read lock succeeds if write locked by current thread even if
469       * other threads are waiting for writelock
470       */
471 <    public void testReadHoldingWriteLock3() {
471 >    public void testReadHoldingWriteLock3() {
472          final ReentrantReadWriteLock lock = new ReentrantReadWriteLock();
473          lock.writeLock().lock();
474          Thread t1 = new Thread(new Runnable() {
# Line 497 | Line 497 | public class ReentrantReadWriteLockTest
497              t2.join(MEDIUM_DELAY_MS);
498              assertTrue(!t1.isAlive());
499              assertTrue(!t2.isAlive());
500 <          
500 >
501          } catch(Exception e){
502              unexpectedException();
503          }
504 <    }
504 >    }
505  
506  
507      /**
508       *  Write lock succeeds if write locked by current thread even if
509       * other threads are waiting for writelock
510       */
511 <    public void testWriteHoldingWriteLock4() {
511 >    public void testWriteHoldingWriteLock4() {
512          final ReentrantReadWriteLock lock = new ReentrantReadWriteLock();
513          lock.writeLock().lock();
514          Thread t1 = new Thread(new Runnable() {
# Line 537 | Line 537 | public class ReentrantReadWriteLockTest
537              t2.join(MEDIUM_DELAY_MS);
538              assertTrue(!t1.isAlive());
539              assertTrue(!t2.isAlive());
540 <          
540 >
541          } catch(Exception e){
542              unexpectedException();
543          }
544 <    }
544 >    }
545  
546  
547      /**
548       * Fair Read trylock succeeds if write locked by current thread
549       */
550 <    public void testReadHoldingWriteLockFair() {
550 >    public void testReadHoldingWriteLockFair() {
551          final ReentrantReadWriteLock lock = new ReentrantReadWriteLock(true);
552          lock.writeLock().lock();
553          assertTrue(lock.readLock().tryLock());
554          lock.readLock().unlock();
555          lock.writeLock().unlock();
556 <    }
556 >    }
557  
558      /**
559       * Fair Read lock succeeds if write locked by current thread even if
560       * other threads are waiting for readlock
561       */
562 <    public void testReadHoldingWriteLockFair2() {
562 >    public void testReadHoldingWriteLockFair2() {
563          final ReentrantReadWriteLock lock = new ReentrantReadWriteLock(true);
564          lock.writeLock().lock();
565          Thread t1 = new Thread(new Runnable() {
# Line 588 | Line 588 | public class ReentrantReadWriteLockTest
588              t2.join(MEDIUM_DELAY_MS);
589              assertTrue(!t1.isAlive());
590              assertTrue(!t2.isAlive());
591 <          
591 >
592          } catch(Exception e){
593              unexpectedException();
594          }
595 <    }
595 >    }
596  
597  
598      /**
599       * Fair Read lock succeeds if write locked by current thread even if
600       * other threads are waiting for writelock
601       */
602 <    public void testReadHoldingWriteLockFair3() {
602 >    public void testReadHoldingWriteLockFair3() {
603          final ReentrantReadWriteLock lock = new ReentrantReadWriteLock(true);
604          lock.writeLock().lock();
605          Thread t1 = new Thread(new Runnable() {
# Line 628 | Line 628 | public class ReentrantReadWriteLockTest
628              t2.join(MEDIUM_DELAY_MS);
629              assertTrue(!t1.isAlive());
630              assertTrue(!t2.isAlive());
631 <          
631 >
632          } catch(Exception e){
633              unexpectedException();
634          }
635 <    }
635 >    }
636  
637  
638      /**
639       * Fair Write lock succeeds if write locked by current thread even if
640       * other threads are waiting for writelock
641       */
642 <    public void testWriteHoldingWriteLockFair4() {
642 >    public void testWriteHoldingWriteLockFair4() {
643          final ReentrantReadWriteLock lock = new ReentrantReadWriteLock(true);
644          lock.writeLock().lock();
645          Thread t1 = new Thread(new Runnable() {
# Line 671 | Line 671 | public class ReentrantReadWriteLockTest
671              t2.join(MEDIUM_DELAY_MS);
672              assertTrue(!t1.isAlive());
673              assertTrue(!t2.isAlive());
674 <          
674 >
675          } catch(Exception e){
676              unexpectedException();
677          }
678 <    }
678 >    }
679  
680  
681      /**
682       * Read tryLock succeeds if readlocked but not writelocked
683       */
684 <    public void testTryLockWhenReadLocked() {
684 >    public void testTryLockWhenReadLocked() {
685          final ReentrantReadWriteLock lock = new ReentrantReadWriteLock();
686          lock.readLock().lock();
687          Thread t = new Thread(new Runnable() {
# Line 697 | Line 697 | public class ReentrantReadWriteLockTest
697          } catch(Exception e){
698              unexpectedException();
699          }
700 <    }
700 >    }
701 >
702  
702    
703  
704      /**
705       * write tryLock fails when readlocked
706       */
707 <    public void testWriteTryLockWhenReadLocked() {
707 >    public void testWriteTryLockWhenReadLocked() {
708          final ReentrantReadWriteLock lock = new ReentrantReadWriteLock();
709          lock.readLock().lock();
710          Thread t = new Thread(new Runnable() {
# Line 719 | Line 719 | public class ReentrantReadWriteLockTest
719          } catch(Exception e){
720              unexpectedException();
721          }
722 <    }
722 >    }
723  
724  
725      /**
726       * Fair Read tryLock succeeds if readlocked but not writelocked
727       */
728 <    public void testTryLockWhenReadLockedFair() {
728 >    public void testTryLockWhenReadLockedFair() {
729          final ReentrantReadWriteLock lock = new ReentrantReadWriteLock(true);
730          lock.readLock().lock();
731          Thread t = new Thread(new Runnable() {
# Line 741 | Line 741 | public class ReentrantReadWriteLockTest
741          } catch(Exception e){
742              unexpectedException();
743          }
744 <    }
744 >    }
745 >
746  
746    
747  
748      /**
749       * Fair write tryLock fails when readlocked
750       */
751 <    public void testWriteTryLockWhenReadLockedFair() {
751 >    public void testWriteTryLockWhenReadLockedFair() {
752          final ReentrantReadWriteLock lock = new ReentrantReadWriteLock(true);
753          lock.readLock().lock();
754          Thread t = new Thread(new Runnable() {
# Line 763 | Line 763 | public class ReentrantReadWriteLockTest
763          } catch(Exception e){
764              unexpectedException();
765          }
766 <    }
766 >    }
767 >
768  
768    
769  
770      /**
771       * write timed tryLock times out if locked
772       */
773 <    public void testWriteTryLock_Timeout() {
773 >    public void testWriteTryLock_Timeout() {
774          final ReentrantReadWriteLock lock = new ReentrantReadWriteLock();
775          lock.writeLock().lock();
776          Thread t = new Thread(new Runnable() {
# Line 789 | Line 789 | public class ReentrantReadWriteLockTest
789          } catch(Exception e){
790              unexpectedException();
791          }
792 <    }
792 >    }
793  
794      /**
795       * read timed tryLock times out if write-locked
796       */
797 <    public void testReadTryLock_Timeout() {
797 >    public void testReadTryLock_Timeout() {
798          final ReentrantReadWriteLock lock = new ReentrantReadWriteLock();
799          lock.writeLock().lock();
800          Thread t = new Thread(new Runnable() {
# Line 813 | Line 813 | public class ReentrantReadWriteLockTest
813          } catch(Exception e){
814              unexpectedException();
815          }
816 <    }
816 >    }
817  
818  
819      /**
# Line 826 | Line 826 | public class ReentrantReadWriteLockTest
826          } catch(Exception e) {
827              unexpectedException();
828          }
829 <        Thread t = new Thread(new Runnable() {
829 >        Thread t = new Thread(new Runnable() {
830                  public void run() {
831                      try {
832                          lock.writeLock().lockInterruptibly();
# Line 858 | Line 858 | public class ReentrantReadWriteLockTest
858          } catch(Exception e) {
859              unexpectedException();
860          }
861 <        Thread t = new Thread(new Runnable() {
861 >        Thread t = new Thread(new Runnable() {
862                  public void run() {
863                      try {
864                          lock.readLock().lockInterruptibly();
# Line 883 | Line 883 | public class ReentrantReadWriteLockTest
883       * Calling await without holding lock throws IllegalMonitorStateException
884       */
885      public void testAwait_IllegalMonitor() {
886 <        final ReentrantReadWriteLock lock = new ReentrantReadWriteLock();      
886 >        final ReentrantReadWriteLock lock = new ReentrantReadWriteLock();
887          final Condition c = lock.writeLock().newCondition();
888          try {
889              c.await();
# Line 900 | Line 900 | public class ReentrantReadWriteLockTest
900       * Calling signal without holding lock throws IllegalMonitorStateException
901       */
902      public void testSignal_IllegalMonitor() {
903 <        final ReentrantReadWriteLock lock = new ReentrantReadWriteLock();      
903 >        final ReentrantReadWriteLock lock = new ReentrantReadWriteLock();
904          final Condition c = lock.writeLock().newCondition();
905          try {
906              c.signal();
# Line 917 | Line 917 | public class ReentrantReadWriteLockTest
917       * awaitNanos without a signal times out
918       */
919      public void testAwaitNanos_Timeout() {
920 <        final ReentrantReadWriteLock lock = new ReentrantReadWriteLock();      
920 >        final ReentrantReadWriteLock lock = new ReentrantReadWriteLock();
921          final Condition c = lock.writeLock().newCondition();
922          try {
923              lock.writeLock().lock();
# Line 935 | Line 935 | public class ReentrantReadWriteLockTest
935       *  timed await without a signal times out
936       */
937      public void testAwait_Timeout() {
938 <        final ReentrantReadWriteLock lock = new ReentrantReadWriteLock();      
938 >        final ReentrantReadWriteLock lock = new ReentrantReadWriteLock();
939          final Condition c = lock.writeLock().newCondition();
940          try {
941              lock.writeLock().lock();
# Line 950 | Line 950 | public class ReentrantReadWriteLockTest
950       * awaitUntil without a signal times out
951       */
952      public void testAwaitUntil_Timeout() {
953 <        final ReentrantReadWriteLock lock = new ReentrantReadWriteLock();      
953 >        final ReentrantReadWriteLock lock = new ReentrantReadWriteLock();
954          final Condition c = lock.writeLock().newCondition();
955          try {
956              lock.writeLock().lock();
# Line 966 | Line 966 | public class ReentrantReadWriteLockTest
966       * await returns when signalled
967       */
968      public void testAwait() {
969 <        final ReentrantReadWriteLock lock = new ReentrantReadWriteLock();      
969 >        final ReentrantReadWriteLock lock = new ReentrantReadWriteLock();
970          final Condition c = lock.writeLock().newCondition();
971 <        Thread t = new Thread(new Runnable() {
971 >        Thread t = new Thread(new Runnable() {
972                  public void run() {
973                      try {
974                          lock.writeLock().lock();
# Line 999 | Line 999 | public class ReentrantReadWriteLockTest
999      class UninterruptableThread extends Thread {
1000          private Lock lock;
1001          private Condition c;
1002 <        
1002 >
1003          public volatile boolean canAwake = false;
1004          public volatile boolean interrupted = false;
1005          public volatile boolean lockStarted = false;
1006 <        
1006 >
1007          public UninterruptableThread(Lock lock, Condition c) {
1008              this.lock = lock;
1009              this.c = c;
1010          }
1011 <        
1011 >
1012          public synchronized void run() {
1013              lock.lock();
1014              lockStarted = true;
1015 <            
1015 >
1016              while (!canAwake) {
1017                  c.awaitUninterruptibly();
1018              }
1019 <            
1019 >
1020              interrupted = isInterrupted();
1021              lock.unlock();
1022          }
# Line 1058 | Line 1058 | public class ReentrantReadWriteLockTest
1058       * await is interruptible
1059       */
1060      public void testAwait_Interrupt() {
1061 <        final ReentrantReadWriteLock lock = new ReentrantReadWriteLock();      
1061 >        final ReentrantReadWriteLock lock = new ReentrantReadWriteLock();
1062          final Condition c = lock.writeLock().newCondition();
1063 <        Thread t = new Thread(new Runnable() {
1063 >        Thread t = new Thread(new Runnable() {
1064                  public void run() {
1065                      try {
1066                          lock.writeLock().lock();
# Line 1089 | Line 1089 | public class ReentrantReadWriteLockTest
1089       * awaitNanos is interruptible
1090       */
1091      public void testAwaitNanos_Interrupt() {
1092 <        final ReentrantReadWriteLock lock = new ReentrantReadWriteLock();      
1092 >        final ReentrantReadWriteLock lock = new ReentrantReadWriteLock();
1093          final Condition c = lock.writeLock().newCondition();
1094 <        Thread t = new Thread(new Runnable() {
1094 >        Thread t = new Thread(new Runnable() {
1095                  public void run() {
1096                      try {
1097                          lock.writeLock().lock();
# Line 1120 | Line 1120 | public class ReentrantReadWriteLockTest
1120       * awaitUntil is interruptible
1121       */
1122      public void testAwaitUntil_Interrupt() {
1123 <        final ReentrantReadWriteLock lock = new ReentrantReadWriteLock();      
1123 >        final ReentrantReadWriteLock lock = new ReentrantReadWriteLock();
1124          final Condition c = lock.writeLock().newCondition();
1125 <        Thread t = new Thread(new Runnable() {
1125 >        Thread t = new Thread(new Runnable() {
1126                  public void run() {
1127                      try {
1128                          lock.writeLock().lock();
# Line 1152 | Line 1152 | public class ReentrantReadWriteLockTest
1152       * signalAll wakes up all threads
1153       */
1154      public void testSignalAll() {
1155 <        final ReentrantReadWriteLock lock = new ReentrantReadWriteLock();      
1155 >        final ReentrantReadWriteLock lock = new ReentrantReadWriteLock();
1156          final Condition c = lock.writeLock().newCondition();
1157 <        Thread t1 = new Thread(new Runnable() {
1157 >        Thread t1 = new Thread(new Runnable() {
1158                  public void run() {
1159                      try {
1160                          lock.writeLock().lock();
# Line 1167 | Line 1167 | public class ReentrantReadWriteLockTest
1167                  }
1168              });
1169  
1170 <        Thread t2 = new Thread(new Runnable() {
1170 >        Thread t2 = new Thread(new Runnable() {
1171                  public void run() {
1172                      try {
1173                          lock.writeLock().lock();
# Line 1225 | Line 1225 | public class ReentrantReadWriteLockTest
1225      /**
1226       * hasQueuedThreads reports whether there are waiting threads
1227       */
1228 <    public void testhasQueuedThreads() {
1228 >    public void testhasQueuedThreads() {
1229          final ReentrantReadWriteLock lock = new ReentrantReadWriteLock();
1230          Thread t1 = new Thread(new InterruptedLockRunnable(lock));
1231          Thread t2 = new Thread(new InterruptibleLockRunnable(lock));
# Line 1249 | Line 1249 | public class ReentrantReadWriteLockTest
1249          } catch(Exception e){
1250              unexpectedException();
1251          }
1252 <    }
1252 >    }
1253  
1254      /**
1255       * hasQueuedThread(null) throws NPE
1256       */
1257 <    public void testHasQueuedThreadNPE() {
1257 >    public void testHasQueuedThreadNPE() {
1258          final ReentrantReadWriteLock sync = new ReentrantReadWriteLock();
1259          try {
1260              sync.hasQueuedThread(null);
# Line 1266 | Line 1266 | public class ReentrantReadWriteLockTest
1266      /**
1267       * hasQueuedThread reports whether a thread is queued.
1268       */
1269 <    public void testHasQueuedThread() {
1269 >    public void testHasQueuedThread() {
1270          final ReentrantReadWriteLock sync = new ReentrantReadWriteLock();
1271          Thread t1 = new Thread(new InterruptedLockRunnable(sync));
1272          Thread t2 = new Thread(new InterruptibleLockRunnable(sync));
# Line 1295 | Line 1295 | public class ReentrantReadWriteLockTest
1295          } catch(Exception e){
1296              unexpectedException();
1297          }
1298 <    }
1298 >    }
1299  
1300  
1301      /**
1302       * getQueueLength reports number of waiting threads
1303       */
1304 <    public void testGetQueueLength() {
1304 >    public void testGetQueueLength() {
1305          final ReentrantReadWriteLock lock = new ReentrantReadWriteLock();
1306          Thread t1 = new Thread(new InterruptedLockRunnable(lock));
1307          Thread t2 = new Thread(new InterruptibleLockRunnable(lock));
# Line 1325 | Line 1325 | public class ReentrantReadWriteLockTest
1325          } catch(Exception e){
1326              unexpectedException();
1327          }
1328 <    }
1328 >    }
1329  
1330      /**
1331       * getQueuedThreads includes waiting threads
1332       */
1333 <    public void testGetQueuedThreads() {
1333 >    public void testGetQueuedThreads() {
1334          final PublicReentrantReadWriteLock lock = new PublicReentrantReadWriteLock();
1335          Thread t1 = new Thread(new InterruptedLockRunnable(lock));
1336          Thread t2 = new Thread(new InterruptibleLockRunnable(lock));
# Line 1357 | Line 1357 | public class ReentrantReadWriteLockTest
1357          } catch(Exception e){
1358              unexpectedException();
1359          }
1360 <    }
1360 >    }
1361  
1362      /**
1363       * hasWaiters throws NPE if null
# Line 1470 | Line 1470 | public class ReentrantReadWriteLockTest
1470       * getWaitingThreads throws IAE if not owned
1471       */
1472      public void testGetWaitingThreadsIAE() {
1473 <        final PublicReentrantReadWriteLock lock = new PublicReentrantReadWriteLock();  
1473 >        final PublicReentrantReadWriteLock lock = new PublicReentrantReadWriteLock();
1474          final Condition c = (lock.writeLock().newCondition());
1475 <        final PublicReentrantReadWriteLock lock2 = new PublicReentrantReadWriteLock();  
1475 >        final PublicReentrantReadWriteLock lock2 = new PublicReentrantReadWriteLock();
1476          try {
1477              lock2.getWaitingThreads(c);
1478              shouldThrow();
# Line 1486 | Line 1486 | public class ReentrantReadWriteLockTest
1486       * getWaitingThreads throws IMSE if not locked
1487       */
1488      public void testGetWaitingThreadsIMSE() {
1489 <        final PublicReentrantReadWriteLock lock = new PublicReentrantReadWriteLock();  
1489 >        final PublicReentrantReadWriteLock lock = new PublicReentrantReadWriteLock();
1490          final Condition c = (lock.writeLock().newCondition());
1491          try {
1492              lock.getWaitingThreads(c);
# Line 1504 | Line 1504 | public class ReentrantReadWriteLockTest
1504      public void testHasWaiters() {
1505          final ReentrantReadWriteLock lock = new ReentrantReadWriteLock();
1506          final Condition c = (lock.writeLock().newCondition());
1507 <        Thread t = new Thread(new Runnable() {
1507 >        Thread t = new Thread(new Runnable() {
1508                  public void run() {
1509                      try {
1510                          lock.writeLock().lock();
# Line 1546 | Line 1546 | public class ReentrantReadWriteLockTest
1546      public void testGetWaitQueueLength() {
1547          final ReentrantReadWriteLock lock = new ReentrantReadWriteLock();
1548          final Condition c = (lock.writeLock().newCondition());
1549 <        Thread t = new Thread(new Runnable() {
1549 >        Thread t = new Thread(new Runnable() {
1550                  public void run() {
1551                      try {
1552                          lock.writeLock().lock();
# Line 1587 | Line 1587 | public class ReentrantReadWriteLockTest
1587       * getWaitingThreads returns only and all waiting threads
1588       */
1589      public void testGetWaitingThreads() {
1590 <        final PublicReentrantReadWriteLock lock = new PublicReentrantReadWriteLock();  
1590 >        final PublicReentrantReadWriteLock lock = new PublicReentrantReadWriteLock();
1591          final Condition c = lock.writeLock().newCondition();
1592 <        Thread t1 = new Thread(new Runnable() {
1592 >        Thread t1 = new Thread(new Runnable() {
1593                  public void run() {
1594                      try {
1595                          lock.writeLock().lock();
# Line 1603 | Line 1603 | public class ReentrantReadWriteLockTest
1603                  }
1604              });
1605  
1606 <        Thread t2 = new Thread(new Runnable() {
1606 >        Thread t2 = new Thread(new Runnable() {
1607                  public void run() {
1608                      try {
1609                          lock.writeLock().lock();

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines