479 |
|
* A writelock succeeds only after a reading thread unlocks |
480 |
|
*/ |
481 |
|
public void testWriteAfterReadLock() throws InterruptedException { |
482 |
< |
final CountDownLatch running = new CountDownLatch(1); |
482 |
> |
final CountDownLatch threadStarted = new CountDownLatch(1); |
483 |
|
final StampedLock lock = new StampedLock(); |
484 |
|
long rs = lock.readLock(); |
485 |
|
Thread t = newStartedThread(new CheckedRunnable() { |
486 |
|
public void realRun() { |
487 |
< |
running.countDown(); |
487 |
> |
threadStarted.countDown(); |
488 |
|
long s = lock.writeLock(); |
489 |
|
lock.unlockWrite(s); |
490 |
|
}}); |
491 |
|
|
492 |
< |
running.await(); |
492 |
> |
threadStarted.await(); |
493 |
|
waitForThreadToEnterWaitState(t, MEDIUM_DELAY_MS); |
494 |
|
assertFalse(lock.isWriteLocked()); |
495 |
|
lock.unlockRead(rs); |