167 |
|
* while waiting. |
168 |
|
*/ |
169 |
|
public void await() throws InterruptedException { |
170 |
+ |
final ReentrantLock lock = this.lock; |
171 |
|
lock.lock(); |
172 |
|
try { |
173 |
|
while (count != 0) |
222 |
|
public boolean await(long timeout, TimeUnit unit) |
223 |
|
throws InterruptedException { |
224 |
|
long nanos = unit.toNanos(timeout); |
225 |
+ |
final ReentrantLock lock = this.lock; |
226 |
|
lock.lock(); |
227 |
|
try { |
228 |
|
for (;;) { |
249 |
|
* happens. |
250 |
|
*/ |
251 |
|
public void countDown() { |
252 |
+ |
final ReentrantLock lock = this.lock; |
253 |
|
lock.lock(); |
254 |
|
try { |
255 |
|
if (count > 0 && --count == 0) |
265 |
|
* @return the current count. |
266 |
|
*/ |
267 |
|
public long getCount() { |
268 |
+ |
final ReentrantLock lock = this.lock; |
269 |
|
lock.lock(); |
270 |
|
try { |
271 |
|
return count; |