190 |
|
*/ |
191 |
|
public void testWriteLockInterruptibly_Interrupted() throws Exception { |
192 |
|
final ReentrantReadWriteLock lock = new ReentrantReadWriteLock(); |
193 |
< |
Thread t = new Thread(new CheckedInterruptedRunnable() { |
193 |
> |
lock.writeLock().lock(); |
194 |
> |
Thread t = newStartedThread(new CheckedInterruptedRunnable() { |
195 |
|
public void realRun() throws InterruptedException { |
196 |
|
lock.writeLock().lockInterruptibly(); |
197 |
|
lock.writeLock().unlock(); |
199 |
|
lock.writeLock().unlock(); |
200 |
|
}}); |
201 |
|
|
201 |
– |
lock.writeLock().lock(); |
202 |
– |
t.start(); |
202 |
|
Thread.sleep(SHORT_DELAY_MS); |
203 |
|
t.interrupt(); |
204 |
|
Thread.sleep(SHORT_DELAY_MS); |
212 |
|
public void testWriteTryLock_Interrupted() throws InterruptedException { |
213 |
|
final ReentrantReadWriteLock lock = new ReentrantReadWriteLock(); |
214 |
|
lock.writeLock().lock(); |
215 |
< |
Thread t = new Thread(new CheckedInterruptedRunnable() { |
215 |
> |
Thread t = newStartedThread(new CheckedInterruptedRunnable() { |
216 |
|
public void realRun() throws InterruptedException { |
217 |
|
lock.writeLock().tryLock(SMALL_DELAY_MS, MILLISECONDS); |
218 |
|
}}); |
219 |
|
|
221 |
– |
t.start(); |
220 |
|
Thread.sleep(SHORT_DELAY_MS); |
221 |
|
t.interrupt(); |
222 |
|
lock.writeLock().unlock(); |
229 |
|
public void testReadLockInterruptibly_Interrupted() throws InterruptedException { |
230 |
|
final ReentrantReadWriteLock lock = new ReentrantReadWriteLock(); |
231 |
|
lock.writeLock().lock(); |
232 |
< |
Thread t = new Thread(new CheckedInterruptedRunnable() { |
232 |
> |
Thread t = newStartedThread(new CheckedInterruptedRunnable() { |
233 |
|
public void realRun() throws InterruptedException { |
234 |
|
lock.readLock().lockInterruptibly(); |
235 |
|
}}); |
236 |
|
|
239 |
– |
t.start(); |
237 |
|
Thread.sleep(SHORT_DELAY_MS); |
238 |
|
t.interrupt(); |
239 |
|
Thread.sleep(SHORT_DELAY_MS); |
247 |
|
public void testReadTryLock_Interrupted() throws InterruptedException { |
248 |
|
final ReentrantReadWriteLock lock = new ReentrantReadWriteLock(); |
249 |
|
lock.writeLock().lock(); |
250 |
< |
Thread t = new Thread(new CheckedInterruptedRunnable() { |
250 |
> |
Thread t = newStartedThread(new CheckedInterruptedRunnable() { |
251 |
|
public void realRun() throws InterruptedException { |
252 |
|
lock.readLock().tryLock(LONG_DELAY_MS, MILLISECONDS); |
253 |
|
}}); |
254 |
|
|
258 |
– |
t.start(); |
255 |
|
Thread.sleep(SHORT_DELAY_MS); |
256 |
|
t.interrupt(); |
257 |
|
t.join(); |
264 |
|
public void testWriteTryLockWhenLocked() throws InterruptedException { |
265 |
|
final ReentrantReadWriteLock lock = new ReentrantReadWriteLock(); |
266 |
|
lock.writeLock().lock(); |
267 |
< |
Thread t = new Thread(new CheckedRunnable() { |
267 |
> |
Thread t = newStartedThread(new CheckedRunnable() { |
268 |
|
public void realRun() { |
269 |
|
assertFalse(lock.writeLock().tryLock()); |
270 |
|
}}); |
271 |
|
|
276 |
– |
t.start(); |
272 |
|
t.join(); |
273 |
|
lock.writeLock().unlock(); |
274 |
|
} |
279 |
|
public void testReadTryLockWhenLocked() throws InterruptedException { |
280 |
|
final ReentrantReadWriteLock lock = new ReentrantReadWriteLock(); |
281 |
|
lock.writeLock().lock(); |
282 |
< |
Thread t = new Thread(new CheckedRunnable() { |
282 |
> |
Thread t = newStartedThread(new CheckedRunnable() { |
283 |
|
public void realRun() { |
284 |
|
assertFalse(lock.readLock().tryLock()); |
285 |
|
}}); |
286 |
|
|
292 |
– |
t.start(); |
287 |
|
t.join(); |
288 |
|
lock.writeLock().unlock(); |
289 |
|
} |
294 |
|
public void testMultipleReadLocks() throws InterruptedException { |
295 |
|
final ReentrantReadWriteLock lock = new ReentrantReadWriteLock(); |
296 |
|
lock.readLock().lock(); |
297 |
< |
Thread t = new Thread(new CheckedRunnable() { |
297 |
> |
Thread t = newStartedThread(new CheckedRunnable() { |
298 |
|
public void realRun() { |
299 |
|
assertTrue(lock.readLock().tryLock()); |
300 |
|
lock.readLock().unlock(); |
301 |
|
}}); |
302 |
|
|
309 |
– |
t.start(); |
303 |
|
t.join(); |
304 |
|
lock.readLock().unlock(); |
305 |
|
} |
310 |
|
public void testWriteAfterMultipleReadLocks() throws InterruptedException { |
311 |
|
final ReentrantReadWriteLock lock = new ReentrantReadWriteLock(); |
312 |
|
lock.readLock().lock(); |
313 |
< |
Thread t1 = new Thread(new CheckedRunnable() { |
313 |
> |
Thread t1 = newStartedThread(new CheckedRunnable() { |
314 |
|
public void realRun() { |
315 |
|
lock.readLock().lock(); |
316 |
|
lock.readLock().unlock(); |
317 |
|
}}); |
318 |
< |
Thread t2 = new Thread(new CheckedRunnable() { |
318 |
> |
Thread t2 = newStartedThread(new CheckedRunnable() { |
319 |
|
public void realRun() { |
320 |
|
lock.writeLock().lock(); |
321 |
|
lock.writeLock().unlock(); |
322 |
|
}}); |
323 |
|
|
331 |
– |
t1.start(); |
332 |
– |
t2.start(); |
324 |
|
Thread.sleep(SHORT_DELAY_MS); |
325 |
|
lock.readLock().unlock(); |
326 |
|
t1.join(MEDIUM_DELAY_MS); |
335 |
|
public void testReadAfterWriteLock() throws InterruptedException { |
336 |
|
final ReentrantReadWriteLock lock = new ReentrantReadWriteLock(); |
337 |
|
lock.writeLock().lock(); |
338 |
< |
Thread t1 = new Thread(new CheckedRunnable() { |
338 |
> |
Thread t1 = newStartedThread(new CheckedRunnable() { |
339 |
|
public void realRun() { |
340 |
|
lock.readLock().lock(); |
341 |
|
lock.readLock().unlock(); |
342 |
|
}}); |
343 |
< |
Thread t2 = new Thread(new CheckedRunnable() { |
343 |
> |
Thread t2 = newStartedThread(new CheckedRunnable() { |
344 |
|
public void realRun() { |
345 |
|
lock.readLock().lock(); |
346 |
|
lock.readLock().unlock(); |
347 |
|
}}); |
348 |
|
|
358 |
– |
t1.start(); |
359 |
– |
t2.start(); |
349 |
|
Thread.sleep(SHORT_DELAY_MS); |
350 |
|
lock.writeLock().unlock(); |
351 |
|
t1.join(MEDIUM_DELAY_MS); |
372 |
|
public void testReadHoldingWriteLock2() throws InterruptedException { |
373 |
|
final ReentrantReadWriteLock lock = new ReentrantReadWriteLock(); |
374 |
|
lock.writeLock().lock(); |
375 |
< |
Thread t1 = new Thread(new CheckedRunnable() { |
375 |
> |
Thread t1 = newStartedThread(new CheckedRunnable() { |
376 |
|
public void realRun() { |
377 |
|
lock.readLock().lock(); |
378 |
|
lock.readLock().unlock(); |
379 |
|
}}); |
380 |
< |
Thread t2 = new Thread(new CheckedRunnable() { |
380 |
> |
Thread t2 = newStartedThread(new CheckedRunnable() { |
381 |
|
public void realRun() { |
382 |
|
lock.readLock().lock(); |
383 |
|
lock.readLock().unlock(); |
384 |
|
}}); |
385 |
|
|
397 |
– |
t1.start(); |
398 |
– |
t2.start(); |
386 |
|
lock.readLock().lock(); |
387 |
|
lock.readLock().unlock(); |
388 |
|
Thread.sleep(SHORT_DELAY_MS); |
402 |
|
public void testReadHoldingWriteLock3() throws InterruptedException { |
403 |
|
final ReentrantReadWriteLock lock = new ReentrantReadWriteLock(); |
404 |
|
lock.writeLock().lock(); |
405 |
< |
Thread t1 = new Thread(new CheckedRunnable() { |
405 |
> |
Thread t1 = newStartedThread(new CheckedRunnable() { |
406 |
|
public void realRun() { |
407 |
|
lock.writeLock().lock(); |
408 |
|
lock.writeLock().unlock(); |
409 |
|
}}); |
410 |
< |
Thread t2 = new Thread(new CheckedRunnable() { |
410 |
> |
Thread t2 = newStartedThread(new CheckedRunnable() { |
411 |
|
public void realRun() { |
412 |
|
lock.writeLock().lock(); |
413 |
|
lock.writeLock().unlock(); |
414 |
|
}}); |
415 |
|
|
429 |
– |
t1.start(); |
430 |
– |
t2.start(); |
416 |
|
lock.readLock().lock(); |
417 |
|
lock.readLock().unlock(); |
418 |
|
Thread.sleep(SHORT_DELAY_MS); |
433 |
|
public void testWriteHoldingWriteLock4() throws InterruptedException { |
434 |
|
final ReentrantReadWriteLock lock = new ReentrantReadWriteLock(); |
435 |
|
lock.writeLock().lock(); |
436 |
< |
Thread t1 = new Thread(new CheckedRunnable() { |
436 |
> |
Thread t1 = newStartedThread(new CheckedRunnable() { |
437 |
|
public void realRun() { |
438 |
|
lock.writeLock().lock(); |
439 |
|
lock.writeLock().unlock(); |
440 |
|
}}); |
441 |
< |
Thread t2 = new Thread(new CheckedRunnable() { |
441 |
> |
Thread t2 = newStartedThread(new CheckedRunnable() { |
442 |
|
public void realRun() { |
443 |
|
lock.writeLock().lock(); |
444 |
|
lock.writeLock().unlock(); |
445 |
|
}}); |
446 |
|
|
462 |
– |
t1.start(); |
463 |
– |
t2.start(); |
447 |
|
lock.writeLock().lock(); |
448 |
|
lock.writeLock().unlock(); |
449 |
|
Thread.sleep(SHORT_DELAY_MS); |
475 |
|
public void testReadHoldingWriteLockFair2() throws InterruptedException { |
476 |
|
final ReentrantReadWriteLock lock = new ReentrantReadWriteLock(true); |
477 |
|
lock.writeLock().lock(); |
478 |
< |
Thread t1 = new Thread(new CheckedRunnable() { |
478 |
> |
Thread t1 = newStartedThread(new CheckedRunnable() { |
479 |
|
public void realRun() { |
480 |
|
lock.readLock().lock(); |
481 |
|
lock.readLock().unlock(); |
482 |
|
}}); |
483 |
< |
Thread t2 = new Thread(new CheckedRunnable() { |
483 |
> |
Thread t2 = newStartedThread(new CheckedRunnable() { |
484 |
|
public void realRun() { |
485 |
|
lock.readLock().lock(); |
486 |
|
lock.readLock().unlock(); |
487 |
|
}}); |
488 |
|
|
506 |
– |
t1.start(); |
507 |
– |
t2.start(); |
489 |
|
lock.readLock().lock(); |
490 |
|
lock.readLock().unlock(); |
491 |
|
Thread.sleep(SHORT_DELAY_MS); |
506 |
|
public void testReadHoldingWriteLockFair3() throws InterruptedException { |
507 |
|
final ReentrantReadWriteLock lock = new ReentrantReadWriteLock(true); |
508 |
|
lock.writeLock().lock(); |
509 |
< |
Thread t1 = new Thread(new CheckedRunnable() { |
509 |
> |
Thread t1 = newStartedThread(new CheckedRunnable() { |
510 |
|
public void realRun() { |
511 |
|
lock.writeLock().lock(); |
512 |
|
lock.writeLock().unlock(); |
513 |
|
}}); |
514 |
< |
Thread t2 = new Thread(new CheckedRunnable() { |
514 |
> |
Thread t2 = newStartedThread(new CheckedRunnable() { |
515 |
|
public void realRun() { |
516 |
|
lock.writeLock().lock(); |
517 |
|
lock.writeLock().unlock(); |
518 |
|
}}); |
519 |
|
|
539 |
– |
t1.start(); |
540 |
– |
t2.start(); |
520 |
|
lock.readLock().lock(); |
521 |
|
lock.readLock().unlock(); |
522 |
|
Thread.sleep(SHORT_DELAY_MS); |
537 |
|
public void testWriteHoldingWriteLockFair4() throws InterruptedException { |
538 |
|
final ReentrantReadWriteLock lock = new ReentrantReadWriteLock(true); |
539 |
|
lock.writeLock().lock(); |
540 |
< |
Thread t1 = new Thread(new CheckedRunnable() { |
540 |
> |
Thread t1 = newStartedThread(new CheckedRunnable() { |
541 |
|
public void realRun() { |
542 |
|
lock.writeLock().lock(); |
543 |
|
lock.writeLock().unlock(); |
544 |
|
}}); |
545 |
< |
Thread t2 = new Thread(new CheckedRunnable() { |
545 |
> |
Thread t2 = newStartedThread(new CheckedRunnable() { |
546 |
|
public void realRun() { |
547 |
|
lock.writeLock().lock(); |
548 |
|
lock.writeLock().unlock(); |
549 |
|
}}); |
550 |
|
|
572 |
– |
t1.start(); |
573 |
– |
t2.start(); |
551 |
|
Thread.sleep(SHORT_DELAY_MS); |
552 |
|
assertTrue(lock.isWriteLockedByCurrentThread()); |
553 |
|
assertEquals(1, lock.getWriteHoldCount()); |
570 |
|
public void testTryLockWhenReadLocked() throws InterruptedException { |
571 |
|
final ReentrantReadWriteLock lock = new ReentrantReadWriteLock(); |
572 |
|
lock.readLock().lock(); |
573 |
< |
Thread t = new Thread(new CheckedRunnable() { |
573 |
> |
Thread t = newStartedThread(new CheckedRunnable() { |
574 |
|
public void realRun() { |
575 |
|
assertTrue(lock.readLock().tryLock()); |
576 |
|
lock.readLock().unlock(); |
577 |
|
}}); |
578 |
|
|
602 |
– |
t.start(); |
579 |
|
t.join(); |
580 |
|
lock.readLock().unlock(); |
581 |
|
} |
582 |
|
|
607 |
– |
|
608 |
– |
|
583 |
|
/** |
584 |
|
* write tryLock fails when readlocked |
585 |
|
*/ |
586 |
|
public void testWriteTryLockWhenReadLocked() throws InterruptedException { |
587 |
|
final ReentrantReadWriteLock lock = new ReentrantReadWriteLock(); |
588 |
|
lock.readLock().lock(); |
589 |
< |
Thread t = new Thread(new CheckedRunnable() { |
589 |
> |
Thread t = newStartedThread(new CheckedRunnable() { |
590 |
|
public void realRun() { |
591 |
|
assertFalse(lock.writeLock().tryLock()); |
592 |
|
}}); |
593 |
|
|
620 |
– |
t.start(); |
594 |
|
t.join(); |
595 |
|
lock.readLock().unlock(); |
596 |
|
} |
602 |
|
public void testTryLockWhenReadLockedFair() throws InterruptedException { |
603 |
|
final ReentrantReadWriteLock lock = new ReentrantReadWriteLock(true); |
604 |
|
lock.readLock().lock(); |
605 |
< |
Thread t = new Thread(new CheckedRunnable() { |
605 |
> |
Thread t = newStartedThread(new CheckedRunnable() { |
606 |
|
public void realRun() { |
607 |
|
assertTrue(lock.readLock().tryLock()); |
608 |
|
lock.readLock().unlock(); |
609 |
|
}}); |
610 |
|
|
638 |
– |
t.start(); |
611 |
|
t.join(); |
612 |
|
lock.readLock().unlock(); |
613 |
|
} |
620 |
|
public void testWriteTryLockWhenReadLockedFair() throws InterruptedException { |
621 |
|
final ReentrantReadWriteLock lock = new ReentrantReadWriteLock(true); |
622 |
|
lock.readLock().lock(); |
623 |
< |
Thread t = new Thread(new CheckedRunnable() { |
623 |
> |
Thread t = newStartedThread(new CheckedRunnable() { |
624 |
|
public void realRun() { |
625 |
|
assertFalse(lock.writeLock().tryLock()); |
626 |
|
}}); |
627 |
|
|
656 |
– |
t.start(); |
628 |
|
t.join(); |
629 |
|
lock.readLock().unlock(); |
630 |
|
} |
637 |
|
public void testWriteTryLock_Timeout() throws InterruptedException { |
638 |
|
final ReentrantReadWriteLock lock = new ReentrantReadWriteLock(); |
639 |
|
lock.writeLock().lock(); |
640 |
< |
Thread t = new Thread(new CheckedRunnable() { |
640 |
> |
Thread t = newStartedThread(new CheckedRunnable() { |
641 |
|
public void realRun() throws InterruptedException { |
642 |
|
assertFalse(lock.writeLock().tryLock(1, MILLISECONDS)); |
643 |
|
}}); |
644 |
|
|
674 |
– |
t.start(); |
645 |
|
t.join(); |
646 |
|
assertTrue(lock.writeLock().isHeldByCurrentThread()); |
647 |
|
lock.writeLock().unlock(); |
653 |
|
public void testReadTryLock_Timeout() throws InterruptedException { |
654 |
|
final ReentrantReadWriteLock lock = new ReentrantReadWriteLock(); |
655 |
|
lock.writeLock().lock(); |
656 |
< |
Thread t = new Thread(new CheckedRunnable() { |
656 |
> |
Thread t = newStartedThread(new CheckedRunnable() { |
657 |
|
public void realRun() throws InterruptedException { |
658 |
|
assertFalse(lock.readLock().tryLock(1, MILLISECONDS)); |
659 |
|
}}); |
660 |
|
|
691 |
– |
t.start(); |
661 |
|
t.join(); |
662 |
|
assertTrue(lock.writeLock().isHeldByCurrentThread()); |
663 |
|
lock.writeLock().unlock(); |
670 |
|
public void testWriteLockInterruptibly() throws InterruptedException { |
671 |
|
final ReentrantReadWriteLock lock = new ReentrantReadWriteLock(); |
672 |
|
lock.writeLock().lockInterruptibly(); |
673 |
< |
Thread t = new Thread(new CheckedInterruptedRunnable() { |
673 |
> |
Thread t = newStartedThread(new CheckedInterruptedRunnable() { |
674 |
|
public void realRun() throws InterruptedException { |
675 |
|
lock.writeLock().lockInterruptibly(); |
676 |
|
}}); |
677 |
|
|
709 |
– |
t.start(); |
678 |
|
Thread.sleep(SHORT_DELAY_MS); |
679 |
|
t.interrupt(); |
680 |
|
Thread.sleep(SHORT_DELAY_MS); |
688 |
|
public void testReadLockInterruptibly() throws InterruptedException { |
689 |
|
final ReentrantReadWriteLock lock = new ReentrantReadWriteLock(); |
690 |
|
lock.writeLock().lockInterruptibly(); |
691 |
< |
Thread t = new Thread(new CheckedInterruptedRunnable() { |
691 |
> |
Thread t = newStartedThread(new CheckedInterruptedRunnable() { |
692 |
|
public void realRun() throws InterruptedException { |
693 |
|
lock.readLock().lockInterruptibly(); |
694 |
|
}}); |
695 |
|
|
728 |
– |
t.start(); |
696 |
|
Thread.sleep(SHORT_DELAY_MS); |
697 |
|
t.interrupt(); |
698 |
|
t.join(); |
766 |
|
public void testAwait() throws InterruptedException { |
767 |
|
final ReentrantReadWriteLock lock = new ReentrantReadWriteLock(); |
768 |
|
final Condition c = lock.writeLock().newCondition(); |
769 |
< |
Thread t = new Thread(new CheckedRunnable() { |
769 |
> |
Thread t = newStartedThread(new CheckedRunnable() { |
770 |
|
public void realRun() throws InterruptedException { |
771 |
|
lock.writeLock().lock(); |
772 |
|
c.await(); |
773 |
|
lock.writeLock().unlock(); |
774 |
|
}}); |
775 |
|
|
809 |
– |
t.start(); |
776 |
|
Thread.sleep(SHORT_DELAY_MS); |
777 |
|
lock.writeLock().lock(); |
778 |
|
c.signal(); |
842 |
|
public void testAwait_Interrupt() throws InterruptedException { |
843 |
|
final ReentrantReadWriteLock lock = new ReentrantReadWriteLock(); |
844 |
|
final Condition c = lock.writeLock().newCondition(); |
845 |
< |
Thread t = new Thread(new CheckedInterruptedRunnable() { |
845 |
> |
Thread t = newStartedThread(new CheckedInterruptedRunnable() { |
846 |
|
public void realRun() throws InterruptedException { |
847 |
|
lock.writeLock().lock(); |
848 |
|
c.await(); |
849 |
|
lock.writeLock().unlock(); |
850 |
|
}}); |
851 |
|
|
886 |
– |
t.start(); |
852 |
|
Thread.sleep(SHORT_DELAY_MS); |
853 |
|
t.interrupt(); |
854 |
|
t.join(SHORT_DELAY_MS); |
861 |
|
public void testAwaitNanos_Interrupt() throws InterruptedException { |
862 |
|
final ReentrantReadWriteLock lock = new ReentrantReadWriteLock(); |
863 |
|
final Condition c = lock.writeLock().newCondition(); |
864 |
< |
Thread t = new Thread(new CheckedInterruptedRunnable() { |
864 |
> |
Thread t = newStartedThread(new CheckedInterruptedRunnable() { |
865 |
|
public void realRun() throws InterruptedException { |
866 |
|
lock.writeLock().lock(); |
867 |
|
c.awaitNanos(MILLISECONDS.toNanos(LONG_DELAY_MS)); |
868 |
|
lock.writeLock().unlock(); |
869 |
|
}}); |
870 |
|
|
906 |
– |
t.start(); |
871 |
|
Thread.sleep(SHORT_DELAY_MS); |
872 |
|
t.interrupt(); |
873 |
|
t.join(SHORT_DELAY_MS); |
880 |
|
public void testAwaitUntil_Interrupt() throws InterruptedException { |
881 |
|
final ReentrantReadWriteLock lock = new ReentrantReadWriteLock(); |
882 |
|
final Condition c = lock.writeLock().newCondition(); |
883 |
< |
Thread t = new Thread(new CheckedInterruptedRunnable() { |
883 |
> |
Thread t = newStartedThread(new CheckedInterruptedRunnable() { |
884 |
|
public void realRun() throws InterruptedException { |
885 |
|
lock.writeLock().lock(); |
886 |
|
java.util.Date d = new java.util.Date(); |
888 |
|
lock.writeLock().unlock(); |
889 |
|
}}); |
890 |
|
|
927 |
– |
t.start(); |
891 |
|
Thread.sleep(SHORT_DELAY_MS); |
892 |
|
t.interrupt(); |
893 |
|
t.join(SHORT_DELAY_MS); |
900 |
|
public void testSignalAll() throws InterruptedException { |
901 |
|
final ReentrantReadWriteLock lock = new ReentrantReadWriteLock(); |
902 |
|
final Condition c = lock.writeLock().newCondition(); |
903 |
< |
Thread t1 = new Thread(new CheckedRunnable() { |
903 |
> |
Thread t1 = newStartedThread(new CheckedRunnable() { |
904 |
|
public void realRun() throws InterruptedException { |
905 |
|
lock.writeLock().lock(); |
906 |
|
c.await(); |
907 |
|
lock.writeLock().unlock(); |
908 |
|
}}); |
909 |
|
|
910 |
< |
Thread t2 = new Thread(new CheckedRunnable() { |
910 |
> |
Thread t2 = newStartedThread(new CheckedRunnable() { |
911 |
|
public void realRun() throws InterruptedException { |
912 |
|
lock.writeLock().lock(); |
913 |
|
c.await(); |
914 |
|
lock.writeLock().unlock(); |
915 |
|
}}); |
916 |
|
|
954 |
– |
t1.start(); |
955 |
– |
t2.start(); |
917 |
|
Thread.sleep(SHORT_DELAY_MS); |
918 |
|
lock.writeLock().lock(); |
919 |
|
c.signalAll(); |
1182 |
|
public void testHasWaiters() throws InterruptedException { |
1183 |
|
final ReentrantReadWriteLock lock = new ReentrantReadWriteLock(); |
1184 |
|
final Condition c = lock.writeLock().newCondition(); |
1185 |
< |
Thread t = new Thread(new CheckedRunnable() { |
1185 |
> |
Thread t = newStartedThread(new CheckedRunnable() { |
1186 |
|
public void realRun() throws InterruptedException { |
1187 |
|
lock.writeLock().lock(); |
1188 |
|
assertFalse(lock.hasWaiters(c)); |
1191 |
|
lock.writeLock().unlock(); |
1192 |
|
}}); |
1193 |
|
|
1233 |
– |
t.start(); |
1194 |
|
Thread.sleep(SHORT_DELAY_MS); |
1195 |
|
lock.writeLock().lock(); |
1196 |
|
assertTrue(lock.hasWaiters(c)); |
1212 |
|
public void testGetWaitQueueLength() throws InterruptedException { |
1213 |
|
final ReentrantReadWriteLock lock = new ReentrantReadWriteLock(); |
1214 |
|
final Condition c = lock.writeLock().newCondition(); |
1215 |
< |
Thread t = new Thread(new CheckedRunnable() { |
1215 |
> |
Thread t = newStartedThread(new CheckedRunnable() { |
1216 |
|
public void realRun() throws InterruptedException { |
1217 |
|
lock.writeLock().lock(); |
1218 |
|
assertFalse(lock.hasWaiters(c)); |
1221 |
|
lock.writeLock().unlock(); |
1222 |
|
}}); |
1223 |
|
|
1264 |
– |
t.start(); |
1224 |
|
Thread.sleep(SHORT_DELAY_MS); |
1225 |
|
lock.writeLock().lock(); |
1226 |
|
assertTrue(lock.hasWaiters(c)); |