59 |
|
} |
60 |
|
|
61 |
|
/** |
62 |
+ |
* Releases 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()); |
68 |
+ |
} |
69 |
+ |
|
70 |
+ |
/** |
71 |
|
* Constructor sets given fairness, and is in unlocked state |
72 |
|
*/ |
73 |
|
public void testConstructor() { |
203 |
|
Thread t = newStartedThread(new CheckedInterruptedRunnable() { |
204 |
|
public void realRun() throws InterruptedException { |
205 |
|
lock.writeLock().lockInterruptibly(); |
197 |
– |
lock.writeLock().unlock(); |
198 |
– |
lock.writeLock().lockInterruptibly(); |
199 |
– |
lock.writeLock().unlock(); |
206 |
|
}}); |
207 |
|
|
208 |
|
Thread.sleep(SHORT_DELAY_MS); |
209 |
|
t.interrupt(); |
204 |
– |
Thread.sleep(SHORT_DELAY_MS); |
205 |
– |
lock.writeLock().unlock(); |
210 |
|
t.join(); |
211 |
+ |
releaseLock(lock.writeLock()); |
212 |
|
} |
213 |
|
|
214 |
|
/** |
224 |
|
|
225 |
|
Thread.sleep(SHORT_DELAY_MS); |
226 |
|
t.interrupt(); |
222 |
– |
lock.writeLock().unlock(); |
227 |
|
t.join(); |
228 |
+ |
releaseLock(lock.writeLock()); |
229 |
|
} |
230 |
|
|
231 |
|
/** |
241 |
|
|
242 |
|
Thread.sleep(SHORT_DELAY_MS); |
243 |
|
t.interrupt(); |
239 |
– |
Thread.sleep(SHORT_DELAY_MS); |
240 |
– |
lock.writeLock().unlock(); |
244 |
|
t.join(); |
245 |
+ |
releaseLock(lock.writeLock()); |
246 |
|
} |
247 |
|
|
248 |
|
/** |
259 |
|
Thread.sleep(SHORT_DELAY_MS); |
260 |
|
t.interrupt(); |
261 |
|
t.join(); |
262 |
+ |
releaseLock(lock.writeLock()); |
263 |
|
} |
264 |
|
|
265 |
|
|
682 |
|
|
683 |
|
Thread.sleep(SHORT_DELAY_MS); |
684 |
|
t.interrupt(); |
680 |
– |
Thread.sleep(SHORT_DELAY_MS); |
685 |
|
t.join(); |
686 |
< |
lock.writeLock().unlock(); |
686 |
> |
releaseLock(lock.writeLock()); |
687 |
|
} |
688 |
|
|
689 |
|
/** |