69 |
|
|
70 |
|
} |
71 |
|
|
72 |
< |
/* |
72 |
> |
/** |
73 |
|
* locking an unlocked lock succeeds |
74 |
|
*/ |
75 |
|
public void testLock() { |
79 |
|
rl.unlock(); |
80 |
|
} |
81 |
|
|
82 |
< |
/* |
82 |
> |
/** |
83 |
|
* locking an unlocked fair lock succeeds |
84 |
|
*/ |
85 |
|
public void testFairLock() { |
89 |
|
rl.unlock(); |
90 |
|
} |
91 |
|
|
92 |
< |
/* |
92 |
> |
/** |
93 |
|
* Unlocking an unlocked lock throws IllegalMonitorStateException |
94 |
|
*/ |
95 |
|
public void testUnlock_IllegalMonitorStateException() { |
101 |
|
} catch(IllegalMonitorStateException success){} |
102 |
|
} |
103 |
|
|
104 |
< |
/* |
104 |
> |
/** |
105 |
|
* trylock on an unlocked lock succeeds |
106 |
|
*/ |
107 |
|
public void testTryLock() { |
112 |
|
} |
113 |
|
|
114 |
|
|
115 |
< |
/* |
116 |
< |
* getLockQueueLength reports number of waiting threads |
115 |
> |
/** |
116 |
> |
* getQueueLength reports number of waiting threads |
117 |
|
*/ |
118 |
< |
public void testGetLockQueueLength() { |
118 |
> |
public void testGetQueueLength() { |
119 |
|
final ReentrantLock lock = new ReentrantLock(); |
120 |
|
Thread t1 = new Thread(new InterruptedLockRunnable(lock)); |
121 |
|
Thread t2 = new Thread(new InterruptibleLockRunnable(lock)); |
122 |
|
try { |
123 |
< |
assertEquals(0, lock.getLockQueueLength()); |
123 |
> |
assertEquals(0, lock.getQueueLength()); |
124 |
|
lock.lock(); |
125 |
|
t1.start(); |
126 |
|
Thread.sleep(SHORT_DELAY_MS); |
127 |
< |
assertEquals(1, lock.getLockQueueLength()); |
127 |
> |
assertEquals(1, lock.getQueueLength()); |
128 |
|
t2.start(); |
129 |
|
Thread.sleep(SHORT_DELAY_MS); |
130 |
< |
assertEquals(2, lock.getLockQueueLength()); |
130 |
> |
assertEquals(2, lock.getQueueLength()); |
131 |
|
t1.interrupt(); |
132 |
|
Thread.sleep(SHORT_DELAY_MS); |
133 |
< |
assertEquals(1, lock.getLockQueueLength()); |
133 |
> |
assertEquals(1, lock.getQueueLength()); |
134 |
|
lock.unlock(); |
135 |
|
Thread.sleep(SHORT_DELAY_MS); |
136 |
< |
assertEquals(0, lock.getLockQueueLength()); |
136 |
> |
assertEquals(0, lock.getQueueLength()); |
137 |
|
t1.join(); |
138 |
|
t2.join(); |
139 |
|
} catch(Exception e){ |
141 |
|
} |
142 |
|
} |
143 |
|
|
144 |
< |
/* |
144 |
> |
/** |
145 |
|
* getQueuedThreads includes waiting threads |
146 |
|
*/ |
147 |
|
public void testGetQueuedThreads() { |
174 |
|
} |
175 |
|
|
176 |
|
|
177 |
< |
/* |
177 |
> |
/** |
178 |
|
* timed trylock is interruptible. |
179 |
|
*/ |
180 |
|
public void testInterruptedException2() { |
290 |
|
} |
291 |
|
|
292 |
|
|
293 |
< |
/* |
293 |
> |
/** |
294 |
|
* lockInterruptibly is interruptible. |
295 |
|
*/ |
296 |
|
public void testLockInterruptibly1() { |