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

Comparing jsr166/src/test/tck/AbstractQueuedLongSynchronizerTest.java (file contents):
Revision 1.22 by jsr166, Tue Mar 15 19:47:06 2011 UTC vs.
Revision 1.23 by dl, Fri May 6 11:22:07 2011 UTC

# Line 134 | Line 134 | public class AbstractQueuedLongSynchroni
134          assertFalse(sync.hasQueuedThreads());
135          sync.acquire(1);
136          t1.start();
137 <        Thread.sleep(SHORT_DELAY_MS);
137 >        delay(SHORT_DELAY_MS);
138          assertTrue(sync.hasQueuedThreads());
139          t2.start();
140 <        Thread.sleep(SHORT_DELAY_MS);
140 >        delay(SHORT_DELAY_MS);
141          assertTrue(sync.hasQueuedThreads());
142          t1.interrupt();
143 <        Thread.sleep(SHORT_DELAY_MS);
143 >        delay(SHORT_DELAY_MS);
144          assertTrue(sync.hasQueuedThreads());
145          sync.release(1);
146 <        Thread.sleep(SHORT_DELAY_MS);
146 >        delay(SHORT_DELAY_MS);
147          assertFalse(sync.hasQueuedThreads());
148          t1.join();
149          t2.join();
# Line 171 | Line 171 | public class AbstractQueuedLongSynchroni
171          assertFalse(sync.isQueued(t2));
172          sync.acquire(1);
173          t1.start();
174 <        Thread.sleep(SHORT_DELAY_MS);
174 >        delay(SHORT_DELAY_MS);
175          assertTrue(sync.isQueued(t1));
176          t2.start();
177 <        Thread.sleep(SHORT_DELAY_MS);
177 >        delay(SHORT_DELAY_MS);
178          assertTrue(sync.isQueued(t1));
179          assertTrue(sync.isQueued(t2));
180          t1.interrupt();
181 <        Thread.sleep(SHORT_DELAY_MS);
181 >        delay(SHORT_DELAY_MS);
182          assertFalse(sync.isQueued(t1));
183          assertTrue(sync.isQueued(t2));
184          sync.release(1);
185 <        Thread.sleep(SHORT_DELAY_MS);
185 >        delay(SHORT_DELAY_MS);
186          assertFalse(sync.isQueued(t1));
187 <        Thread.sleep(SHORT_DELAY_MS);
187 >        delay(SHORT_DELAY_MS);
188          assertFalse(sync.isQueued(t2));
189          t1.join();
190          t2.join();
# Line 200 | Line 200 | public class AbstractQueuedLongSynchroni
200          assertNull(sync.getFirstQueuedThread());
201          sync.acquire(1);
202          t1.start();
203 <        Thread.sleep(SHORT_DELAY_MS);
203 >        delay(SHORT_DELAY_MS);
204          assertEquals(t1, sync.getFirstQueuedThread());
205          t2.start();
206 <        Thread.sleep(SHORT_DELAY_MS);
206 >        delay(SHORT_DELAY_MS);
207          assertEquals(t1, sync.getFirstQueuedThread());
208          t1.interrupt();
209 <        Thread.sleep(SHORT_DELAY_MS);
210 <        Thread.sleep(SHORT_DELAY_MS);
209 >        delay(SHORT_DELAY_MS);
210 >        delay(SHORT_DELAY_MS);
211          assertEquals(t2, sync.getFirstQueuedThread());
212          sync.release(1);
213 <        Thread.sleep(SHORT_DELAY_MS);
213 >        delay(SHORT_DELAY_MS);
214          assertNull(sync.getFirstQueuedThread());
215          t1.join();
216          t2.join();
# Line 227 | Line 227 | public class AbstractQueuedLongSynchroni
227          assertFalse(sync.hasContended());
228          sync.acquire(1);
229          t1.start();
230 <        Thread.sleep(SHORT_DELAY_MS);
230 >        delay(SHORT_DELAY_MS);
231          assertTrue(sync.hasContended());
232          t2.start();
233 <        Thread.sleep(SHORT_DELAY_MS);
233 >        delay(SHORT_DELAY_MS);
234          assertTrue(sync.hasContended());
235          t1.interrupt();
236 <        Thread.sleep(SHORT_DELAY_MS);
236 >        delay(SHORT_DELAY_MS);
237          assertTrue(sync.hasContended());
238          sync.release(1);
239 <        Thread.sleep(SHORT_DELAY_MS);
239 >        delay(SHORT_DELAY_MS);
240          assertTrue(sync.hasContended());
241          t1.join();
242          t2.join();
# Line 253 | Line 253 | public class AbstractQueuedLongSynchroni
253          sync.acquire(1);
254          assertTrue(sync.getQueuedThreads().isEmpty());
255          t1.start();
256 <        Thread.sleep(SHORT_DELAY_MS);
256 >        delay(SHORT_DELAY_MS);
257          assertTrue(sync.getQueuedThreads().contains(t1));
258          t2.start();
259 <        Thread.sleep(SHORT_DELAY_MS);
259 >        delay(SHORT_DELAY_MS);
260          assertTrue(sync.getQueuedThreads().contains(t1));
261          assertTrue(sync.getQueuedThreads().contains(t2));
262          t1.interrupt();
263 <        Thread.sleep(SHORT_DELAY_MS);
263 >        delay(SHORT_DELAY_MS);
264          assertFalse(sync.getQueuedThreads().contains(t1));
265          assertTrue(sync.getQueuedThreads().contains(t2));
266          sync.release(1);
267 <        Thread.sleep(SHORT_DELAY_MS);
267 >        delay(SHORT_DELAY_MS);
268          assertTrue(sync.getQueuedThreads().isEmpty());
269          t1.join();
270          t2.join();
# Line 281 | Line 281 | public class AbstractQueuedLongSynchroni
281          sync.acquire(1);
282          assertTrue(sync.getExclusiveQueuedThreads().isEmpty());
283          t1.start();
284 <        Thread.sleep(SHORT_DELAY_MS);
284 >        delay(SHORT_DELAY_MS);
285          assertTrue(sync.getExclusiveQueuedThreads().contains(t1));
286          t2.start();
287 <        Thread.sleep(SHORT_DELAY_MS);
287 >        delay(SHORT_DELAY_MS);
288          assertTrue(sync.getExclusiveQueuedThreads().contains(t1));
289          assertTrue(sync.getExclusiveQueuedThreads().contains(t2));
290          t1.interrupt();
291 <        Thread.sleep(SHORT_DELAY_MS);
291 >        delay(SHORT_DELAY_MS);
292          assertFalse(sync.getExclusiveQueuedThreads().contains(t1));
293          assertTrue(sync.getExclusiveQueuedThreads().contains(t2));
294          sync.release(1);
295 <        Thread.sleep(SHORT_DELAY_MS);
295 >        delay(SHORT_DELAY_MS);
296          assertTrue(sync.getExclusiveQueuedThreads().isEmpty());
297          t1.join();
298          t2.join();
# Line 309 | Line 309 | public class AbstractQueuedLongSynchroni
309          sync.acquire(1);
310          assertTrue(sync.getSharedQueuedThreads().isEmpty());
311          t1.start();
312 <        Thread.sleep(SHORT_DELAY_MS);
312 >        delay(SHORT_DELAY_MS);
313          assertTrue(sync.getSharedQueuedThreads().isEmpty());
314          t2.start();
315 <        Thread.sleep(SHORT_DELAY_MS);
315 >        delay(SHORT_DELAY_MS);
316          assertTrue(sync.getSharedQueuedThreads().isEmpty());
317          t1.interrupt();
318 <        Thread.sleep(SHORT_DELAY_MS);
318 >        delay(SHORT_DELAY_MS);
319          assertTrue(sync.getSharedQueuedThreads().isEmpty());
320          sync.release(1);
321 <        Thread.sleep(SHORT_DELAY_MS);
321 >        delay(SHORT_DELAY_MS);
322          assertTrue(sync.getSharedQueuedThreads().isEmpty());
323          t1.join();
324          t2.join();
# Line 336 | Line 336 | public class AbstractQueuedLongSynchroni
336              }});
337  
338          t.start();
339 <        Thread.sleep(SHORT_DELAY_MS);
339 >        delay(SHORT_DELAY_MS);
340          t.interrupt();
341          t.join();
342      }
# Line 388 | Line 388 | public class AbstractQueuedLongSynchroni
388          Thread t = new Thread(new CheckedRunnable() {
389              public void realRun() throws InterruptedException {
390                  sync.acquire(1);
391 <                Thread.sleep(SMALL_DELAY_MS);
391 >                delay(SMALL_DELAY_MS);
392                  sync.release(1);
393              }});
394  
395          t.start();
396 <        Thread.sleep(SHORT_DELAY_MS);
396 >        delay(SHORT_DELAY_MS);
397          assertTrue(sync.isHeldExclusively());
398          t.join();
399          assertFalse(sync.isHeldExclusively());
# Line 408 | Line 408 | public class AbstractQueuedLongSynchroni
408          sync.acquire(1);
409          Thread t = new Thread(new InterruptedSyncRunnable(sync));
410          t.start();
411 <        Thread.sleep(SHORT_DELAY_MS);
411 >        delay(SHORT_DELAY_MS);
412          t.interrupt();
413 <        Thread.sleep(SHORT_DELAY_MS);
413 >        delay(SHORT_DELAY_MS);
414          sync.release(1);
415          t.join();
416      }
# Line 423 | Line 423 | public class AbstractQueuedLongSynchroni
423          sync.acquireInterruptibly(1);
424          Thread t = new Thread(new InterruptedSyncRunnable(sync));
425          t.start();
426 <        Thread.sleep(SHORT_DELAY_MS);
426 >        delay(SHORT_DELAY_MS);
427          t.interrupt();
428          assertTrue(sync.isHeldExclusively());
429          t.join();
# Line 513 | Line 513 | public class AbstractQueuedLongSynchroni
513              }});
514  
515          t.start();
516 <        Thread.sleep(SHORT_DELAY_MS);
516 >        delay(SHORT_DELAY_MS);
517          sync.acquire(1);
518          c.signal();
519          sync.release(1);
# Line 653 | Line 653 | public class AbstractQueuedLongSynchroni
653              }});
654  
655          t.start();
656 <        Thread.sleep(SHORT_DELAY_MS);
656 >        delay(SHORT_DELAY_MS);
657          sync.acquire(1);
658          assertTrue(sync.hasWaiters(c));
659          assertEquals(1, sync.getWaitQueueLength(c));
660          c.signal();
661          sync.release(1);
662 <        Thread.sleep(SHORT_DELAY_MS);
662 >        delay(SHORT_DELAY_MS);
663          sync.acquire(1);
664          assertFalse(sync.hasWaiters(c));
665          assertEquals(0, sync.getWaitQueueLength(c));
# Line 693 | Line 693 | public class AbstractQueuedLongSynchroni
693              }});
694  
695          t1.start();
696 <        Thread.sleep(SHORT_DELAY_MS);
696 >        delay(SHORT_DELAY_MS);
697          t2.start();
698 <        Thread.sleep(SHORT_DELAY_MS);
698 >        delay(SHORT_DELAY_MS);
699          sync.acquire(1);
700          assertTrue(sync.hasWaiters(c));
701          assertEquals(2, sync.getWaitQueueLength(c));
702          c.signalAll();
703          sync.release(1);
704 <        Thread.sleep(SHORT_DELAY_MS);
704 >        delay(SHORT_DELAY_MS);
705          sync.acquire(1);
706          assertFalse(sync.hasWaiters(c));
707          assertEquals(0, sync.getWaitQueueLength(c));
# Line 738 | Line 738 | public class AbstractQueuedLongSynchroni
738              assertTrue(sync.getWaitingThreads(c).isEmpty());
739              sync.release(1);
740              t1.start();
741 <            Thread.sleep(SHORT_DELAY_MS);
741 >            delay(SHORT_DELAY_MS);
742              t2.start();
743 <            Thread.sleep(SHORT_DELAY_MS);
743 >            delay(SHORT_DELAY_MS);
744              sync.acquire(1);
745              assertTrue(sync.hasWaiters(c));
746              assertTrue(sync.getWaitingThreads(c).contains(t1));
747              assertTrue(sync.getWaitingThreads(c).contains(t2));
748              c.signalAll();
749              sync.release(1);
750 <            Thread.sleep(SHORT_DELAY_MS);
750 >            delay(SHORT_DELAY_MS);
751              sync.acquire(1);
752              assertFalse(sync.hasWaiters(c));
753              assertTrue(sync.getWaitingThreads(c).isEmpty());
# Line 774 | Line 774 | public class AbstractQueuedLongSynchroni
774              }});
775  
776          t.start();
777 <        Thread.sleep(SHORT_DELAY_MS);
777 >        delay(SHORT_DELAY_MS);
778          t.interrupt();
779          sync.acquire(1);
780          c.signal();
# Line 796 | Line 796 | public class AbstractQueuedLongSynchroni
796              }});
797  
798          t.start();
799 <        Thread.sleep(SHORT_DELAY_MS);
799 >        delay(SHORT_DELAY_MS);
800          t.interrupt();
801          t.join(SHORT_DELAY_MS);
802          assertFalse(t.isAlive());
# Line 815 | Line 815 | public class AbstractQueuedLongSynchroni
815              }});
816  
817          t.start();
818 <        Thread.sleep(SHORT_DELAY_MS);
818 >        delay(SHORT_DELAY_MS);
819          t.interrupt();
820          t.join(SHORT_DELAY_MS);
821          assertFalse(t.isAlive());
# Line 835 | Line 835 | public class AbstractQueuedLongSynchroni
835              }});
836  
837          t.start();
838 <        Thread.sleep(SHORT_DELAY_MS);
838 >        delay(SHORT_DELAY_MS);
839          t.interrupt();
840          t.join(SHORT_DELAY_MS);
841          assertFalse(t.isAlive());
# Line 863 | Line 863 | public class AbstractQueuedLongSynchroni
863  
864          t1.start();
865          t2.start();
866 <        Thread.sleep(SHORT_DELAY_MS);
866 >        delay(SHORT_DELAY_MS);
867          sync.acquire(1);
868          c.signalAll();
869          sync.release(1);
# Line 943 | Line 943 | public class AbstractQueuedLongSynchroni
943  
944          t.start();
945          assertFalse(l.isSignalled());
946 <        Thread.sleep(SHORT_DELAY_MS);
946 >        delay(SHORT_DELAY_MS);
947          l.releaseShared(0);
948          assertTrue(l.isSignalled());
949          t.join();
# Line 966 | Line 966 | public class AbstractQueuedLongSynchroni
966  
967          t.start();
968          assertFalse(l.isSignalled());
969 <        Thread.sleep(SHORT_DELAY_MS);
969 >        delay(SHORT_DELAY_MS);
970          l.releaseShared(0);
971          assertTrue(l.isSignalled());
972          t.join();
# Line 1003 | Line 1003 | public class AbstractQueuedLongSynchroni
1003              }});
1004  
1005          t.start();
1006 <        Thread.sleep(SHORT_DELAY_MS);
1006 >        delay(SHORT_DELAY_MS);
1007          assertFalse(l.isSignalled());
1008          t.interrupt();
1009          t.join();
# Line 1022 | Line 1022 | public class AbstractQueuedLongSynchroni
1022              }});
1023  
1024          t.start();
1025 <        Thread.sleep(SHORT_DELAY_MS);
1025 >        delay(SHORT_DELAY_MS);
1026          assertFalse(l.isSignalled());
1027          t.join();
1028      }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines