59 |
|
} |
60 |
|
|
61 |
|
/** |
62 |
< |
* Releases lock, checking that it had a hold count of 1. |
62 |
> |
* Releases write lock, checking that it had a hold count of 1. |
63 |
|
*/ |
64 |
< |
void releaseLock(ReentrantReadWriteLock.WriteLock lock) { |
65 |
< |
assertTrue(lock.isHeldByCurrentThread()); |
66 |
< |
lock.unlock(); |
67 |
< |
assertFalse(lock.isHeldByCurrentThread()); |
64 |
> |
void releaseWriteLock(ReentrantReadWriteLock lock) { |
65 |
> |
ReentrantReadWriteLock.WriteLock writeLock = lock.writeLock(); |
66 |
> |
assertTrue(writeLock.isHeldByCurrentThread()); |
67 |
> |
writeLock.unlock(); |
68 |
> |
assertFalse(writeLock.isHeldByCurrentThread()); |
69 |
|
} |
70 |
|
|
71 |
|
/** |
209 |
|
Thread.sleep(SHORT_DELAY_MS); |
210 |
|
t.interrupt(); |
211 |
|
awaitTermination(t, LONG_DELAY_MS); |
212 |
< |
releaseLock(lock.writeLock()); |
212 |
> |
releaseWriteLock(lock); |
213 |
|
} |
214 |
|
|
215 |
|
/** |
226 |
|
Thread.sleep(SHORT_DELAY_MS); |
227 |
|
t.interrupt(); |
228 |
|
awaitTermination(t, LONG_DELAY_MS); |
229 |
< |
releaseLock(lock.writeLock()); |
229 |
> |
releaseWriteLock(lock); |
230 |
|
} |
231 |
|
|
232 |
|
/** |
243 |
|
Thread.sleep(SHORT_DELAY_MS); |
244 |
|
t.interrupt(); |
245 |
|
awaitTermination(t, LONG_DELAY_MS); |
246 |
< |
releaseLock(lock.writeLock()); |
246 |
> |
releaseWriteLock(lock); |
247 |
|
} |
248 |
|
|
249 |
|
/** |
260 |
|
Thread.sleep(SHORT_DELAY_MS); |
261 |
|
t.interrupt(); |
262 |
|
awaitTermination(t, LONG_DELAY_MS); |
263 |
< |
releaseLock(lock.writeLock()); |
263 |
> |
releaseWriteLock(lock); |
264 |
|
} |
265 |
|
|
266 |
|
|
276 |
|
}}); |
277 |
|
|
278 |
|
awaitTermination(t, LONG_DELAY_MS); |
279 |
< |
lock.writeLock().unlock(); |
279 |
> |
releaseWriteLock(lock); |
280 |
|
} |
281 |
|
|
282 |
|
/** |
291 |
|
}}); |
292 |
|
|
293 |
|
awaitTermination(t, LONG_DELAY_MS); |
294 |
< |
lock.writeLock().unlock(); |
294 |
> |
releaseWriteLock(lock); |
295 |
|
} |
296 |
|
|
297 |
|
/** |
351 |
|
}}); |
352 |
|
|
353 |
|
Thread.sleep(SHORT_DELAY_MS); |
354 |
< |
lock.writeLock().unlock(); |
354 |
> |
assertTrue(t1.isAlive()); |
355 |
> |
assertTrue(t2.isAlive()); |
356 |
> |
releaseWriteLock(lock); |
357 |
|
awaitTermination(t1, LONG_DELAY_MS); |
358 |
|
awaitTermination(t2, LONG_DELAY_MS); |
359 |
|
} |
670 |
|
Thread.sleep(SHORT_DELAY_MS); |
671 |
|
t.interrupt(); |
672 |
|
awaitTermination(t, LONG_DELAY_MS); |
673 |
< |
releaseLock(lock.writeLock()); |
673 |
> |
releaseWriteLock(lock); |
674 |
|
} |
675 |
|
|
676 |
|
/** |
687 |
|
Thread.sleep(SHORT_DELAY_MS); |
688 |
|
t.interrupt(); |
689 |
|
awaitTermination(t, LONG_DELAY_MS); |
690 |
< |
releaseLock(lock.writeLock()); |
690 |
> |
releaseWriteLock(lock); |
691 |
|
} |
692 |
|
|
693 |
|
/** |