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.39 by jsr166, Tue Mar 15 19:47:07 2011 UTC vs.
Revision 1.40 by dl, Fri May 6 11:22:07 2011 UTC

# Line 120 | Line 120 | public class ReentrantLockTest extends J
120          assertFalse(lock.hasQueuedThreads());
121          lock.lock();
122          t1.start();
123 <        Thread.sleep(SHORT_DELAY_MS);
123 >        delay(SHORT_DELAY_MS);
124          assertTrue(lock.hasQueuedThreads());
125          t2.start();
126 <        Thread.sleep(SHORT_DELAY_MS);
126 >        delay(SHORT_DELAY_MS);
127          assertTrue(lock.hasQueuedThreads());
128          t1.interrupt();
129 <        Thread.sleep(SHORT_DELAY_MS);
129 >        delay(SHORT_DELAY_MS);
130          assertTrue(lock.hasQueuedThreads());
131          lock.unlock();
132 <        Thread.sleep(SHORT_DELAY_MS);
132 >        delay(SHORT_DELAY_MS);
133          assertFalse(lock.hasQueuedThreads());
134          t1.join();
135          t2.join();
# Line 145 | Line 145 | public class ReentrantLockTest extends J
145          assertEquals(0, lock.getQueueLength());
146          lock.lock();
147          t1.start();
148 <        Thread.sleep(SHORT_DELAY_MS);
148 >        delay(SHORT_DELAY_MS);
149          assertEquals(1, lock.getQueueLength());
150          t2.start();
151 <        Thread.sleep(SHORT_DELAY_MS);
151 >        delay(SHORT_DELAY_MS);
152          assertEquals(2, lock.getQueueLength());
153          t1.interrupt();
154 <        Thread.sleep(SHORT_DELAY_MS);
154 >        delay(SHORT_DELAY_MS);
155          assertEquals(1, lock.getQueueLength());
156          lock.unlock();
157 <        Thread.sleep(SHORT_DELAY_MS);
157 >        delay(SHORT_DELAY_MS);
158          assertEquals(0, lock.getQueueLength());
159          t1.join();
160          t2.join();
# Line 170 | Line 170 | public class ReentrantLockTest extends J
170          assertEquals(0, lock.getQueueLength());
171          lock.lock();
172          t1.start();
173 <        Thread.sleep(SHORT_DELAY_MS);
173 >        delay(SHORT_DELAY_MS);
174          assertEquals(1, lock.getQueueLength());
175          t2.start();
176 <        Thread.sleep(SHORT_DELAY_MS);
176 >        delay(SHORT_DELAY_MS);
177          assertEquals(2, lock.getQueueLength());
178          t1.interrupt();
179 <        Thread.sleep(SHORT_DELAY_MS);
179 >        delay(SHORT_DELAY_MS);
180          assertEquals(1, lock.getQueueLength());
181          lock.unlock();
182 <        Thread.sleep(SHORT_DELAY_MS);
182 >        delay(SHORT_DELAY_MS);
183          assertEquals(0, lock.getQueueLength());
184          t1.join();
185          t2.join();
# Line 207 | Line 207 | public class ReentrantLockTest extends J
207          assertFalse(sync.hasQueuedThread(t2));
208          sync.lock();
209          t1.start();
210 <        Thread.sleep(SHORT_DELAY_MS);
210 >        delay(SHORT_DELAY_MS);
211          assertTrue(sync.hasQueuedThread(t1));
212          t2.start();
213 <        Thread.sleep(SHORT_DELAY_MS);
213 >        delay(SHORT_DELAY_MS);
214          assertTrue(sync.hasQueuedThread(t1));
215          assertTrue(sync.hasQueuedThread(t2));
216          t1.interrupt();
217 <        Thread.sleep(SHORT_DELAY_MS);
217 >        delay(SHORT_DELAY_MS);
218          assertFalse(sync.hasQueuedThread(t1));
219          assertTrue(sync.hasQueuedThread(t2));
220          sync.unlock();
221 <        Thread.sleep(SHORT_DELAY_MS);
221 >        delay(SHORT_DELAY_MS);
222          assertFalse(sync.hasQueuedThread(t1));
223 <        Thread.sleep(SHORT_DELAY_MS);
223 >        delay(SHORT_DELAY_MS);
224          assertFalse(sync.hasQueuedThread(t2));
225          t1.join();
226          t2.join();
# Line 238 | Line 238 | public class ReentrantLockTest extends J
238          lock.lock();
239          assertTrue(lock.getQueuedThreads().isEmpty());
240          t1.start();
241 <        Thread.sleep(SHORT_DELAY_MS);
241 >        delay(SHORT_DELAY_MS);
242          assertTrue(lock.getQueuedThreads().contains(t1));
243          t2.start();
244 <        Thread.sleep(SHORT_DELAY_MS);
244 >        delay(SHORT_DELAY_MS);
245          assertTrue(lock.getQueuedThreads().contains(t1));
246          assertTrue(lock.getQueuedThreads().contains(t2));
247          t1.interrupt();
248 <        Thread.sleep(SHORT_DELAY_MS);
248 >        delay(SHORT_DELAY_MS);
249          assertFalse(lock.getQueuedThreads().contains(t1));
250          assertTrue(lock.getQueuedThreads().contains(t2));
251          lock.unlock();
252 <        Thread.sleep(SHORT_DELAY_MS);
252 >        delay(SHORT_DELAY_MS);
253          assertTrue(lock.getQueuedThreads().isEmpty());
254          t1.join();
255          t2.join();
# Line 268 | Line 268 | public class ReentrantLockTest extends J
268              }});
269  
270          t.start();
271 <        Thread.sleep(SHORT_DELAY_MS);
271 >        delay(SHORT_DELAY_MS);
272          t.interrupt();
273          t.join();
274      }
# Line 334 | Line 334 | public class ReentrantLockTest extends J
334          Thread t = new Thread(new CheckedRunnable() {
335              public void realRun() throws InterruptedException {
336                  lock.lock();
337 <                Thread.sleep(SMALL_DELAY_MS);
337 >                delay(SMALL_DELAY_MS);
338                  lock.unlock();
339              }});
340  
341          t.start();
342 <        Thread.sleep(SHORT_DELAY_MS);
342 >        delay(SHORT_DELAY_MS);
343          assertTrue(lock.isLocked());
344          t.join();
345          assertFalse(lock.isLocked());
# Line 354 | Line 354 | public class ReentrantLockTest extends J
354          lock.lock();
355          Thread t = new Thread(new InterruptedLockRunnable(lock));
356          t.start();
357 <        Thread.sleep(SHORT_DELAY_MS);
357 >        delay(SHORT_DELAY_MS);
358          t.interrupt();
359 <        Thread.sleep(SHORT_DELAY_MS);
359 >        delay(SHORT_DELAY_MS);
360          lock.unlock();
361          t.join();
362      }
# Line 369 | Line 369 | public class ReentrantLockTest extends J
369          lock.lockInterruptibly();
370          Thread t = new Thread(new InterruptedLockRunnable(lock));
371          t.start();
372 <        Thread.sleep(SHORT_DELAY_MS);
372 >        delay(SHORT_DELAY_MS);
373          t.interrupt();
374          assertTrue(lock.isLocked());
375          assertTrue(lock.isHeldByCurrentThread());
# Line 449 | Line 449 | public class ReentrantLockTest extends J
449              }});
450  
451          t.start();
452 <        Thread.sleep(SHORT_DELAY_MS);
452 >        delay(SHORT_DELAY_MS);
453          lock.lock();
454          c.signal();
455          lock.unlock();
# Line 586 | Line 586 | public class ReentrantLockTest extends J
586              }});
587  
588          t.start();
589 <        Thread.sleep(SHORT_DELAY_MS);
589 >        delay(SHORT_DELAY_MS);
590          lock.lock();
591          assertTrue(lock.hasWaiters(c));
592          assertEquals(1, lock.getWaitQueueLength(c));
593          c.signal();
594          lock.unlock();
595 <        Thread.sleep(SHORT_DELAY_MS);
595 >        delay(SHORT_DELAY_MS);
596          lock.lock();
597          assertFalse(lock.hasWaiters(c));
598          assertEquals(0, lock.getWaitQueueLength(c));
# Line 626 | Line 626 | public class ReentrantLockTest extends J
626              }});
627  
628          t1.start();
629 <        Thread.sleep(SHORT_DELAY_MS);
629 >        delay(SHORT_DELAY_MS);
630          t2.start();
631 <        Thread.sleep(SHORT_DELAY_MS);
631 >        delay(SHORT_DELAY_MS);
632          lock.lock();
633          assertTrue(lock.hasWaiters(c));
634          assertEquals(2, lock.getWaitQueueLength(c));
635          c.signalAll();
636          lock.unlock();
637 <        Thread.sleep(SHORT_DELAY_MS);
637 >        delay(SHORT_DELAY_MS);
638          lock.lock();
639          assertFalse(lock.hasWaiters(c));
640          assertEquals(0, lock.getWaitQueueLength(c));
# Line 671 | Line 671 | public class ReentrantLockTest extends J
671          assertTrue(lock.getWaitingThreads(c).isEmpty());
672          lock.unlock();
673          t1.start();
674 <        Thread.sleep(SHORT_DELAY_MS);
674 >        delay(SHORT_DELAY_MS);
675          t2.start();
676 <        Thread.sleep(SHORT_DELAY_MS);
676 >        delay(SHORT_DELAY_MS);
677          lock.lock();
678          assertTrue(lock.hasWaiters(c));
679          assertTrue(lock.getWaitingThreads(c).contains(t1));
680          assertTrue(lock.getWaitingThreads(c).contains(t2));
681          c.signalAll();
682          lock.unlock();
683 <        Thread.sleep(SHORT_DELAY_MS);
683 >        delay(SHORT_DELAY_MS);
684          lock.lock();
685          assertFalse(lock.hasWaiters(c));
686          assertTrue(lock.getWaitingThreads(c).isEmpty());
# Line 729 | Line 729 | public class ReentrantLockTest extends J
729          thread.start();
730  
731          while (!thread.lockStarted) {
732 <            Thread.sleep(100);
732 >            delay(100);
733          }
734  
735          lock.lock();
# Line 759 | Line 759 | public class ReentrantLockTest extends J
759              }});
760  
761          t.start();
762 <        Thread.sleep(SHORT_DELAY_MS);
762 >        delay(SHORT_DELAY_MS);
763          t.interrupt();
764          t.join(SHORT_DELAY_MS);
765          assertFalse(t.isAlive());
# Line 778 | Line 778 | public class ReentrantLockTest extends J
778              }});
779  
780          t.start();
781 <        Thread.sleep(SHORT_DELAY_MS);
781 >        delay(SHORT_DELAY_MS);
782          t.interrupt();
783          t.join(SHORT_DELAY_MS);
784          assertFalse(t.isAlive());
# Line 798 | Line 798 | public class ReentrantLockTest extends J
798              }});
799  
800          t.start();
801 <        Thread.sleep(SHORT_DELAY_MS);
801 >        delay(SHORT_DELAY_MS);
802          t.interrupt();
803          t.join(SHORT_DELAY_MS);
804          assertFalse(t.isAlive());
# Line 826 | Line 826 | public class ReentrantLockTest extends J
826  
827          t1.start();
828          t2.start();
829 <        Thread.sleep(SHORT_DELAY_MS);
829 >        delay(SHORT_DELAY_MS);
830          lock.lock();
831          c.signalAll();
832          lock.unlock();
# Line 864 | Line 864 | public class ReentrantLockTest extends J
864  
865          t1.start();
866          t2.start();
867 <        Thread.sleep(SHORT_DELAY_MS);
867 >        delay(SHORT_DELAY_MS);
868          lock.lock();
869          c.signalAll();
870          lock.unlock();

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines