142 |
|
*/ |
143 |
|
private int dowait(boolean timed, long nanos) |
144 |
|
throws InterruptedException, BrokenBarrierException, TimeoutException { |
145 |
+ |
final ReentrantLock lock = this.lock; |
146 |
|
lock.lock(); |
147 |
|
try { |
148 |
|
int index = --count; |
160 |
|
nextGeneration(); |
161 |
|
boolean ranAction = false; |
162 |
|
try { |
163 |
< |
if (barrierCommand != null) |
164 |
< |
barrierCommand.run(); |
163 |
> |
Runnable command = barrierCommand; |
164 |
> |
if (command != null) |
165 |
> |
command.run(); |
166 |
|
ranAction = true; |
167 |
|
return 0; |
168 |
|
} finally { |
375 |
|
* and <tt>false</tt> otherwise. |
376 |
|
*/ |
377 |
|
public boolean isBroken() { |
378 |
+ |
final ReentrantLock lock = this.lock; |
379 |
|
lock.lock(); |
380 |
|
try { |
381 |
|
return broken; |
394 |
|
* instead create a new barrier for subsequent use. |
395 |
|
*/ |
396 |
|
public void reset() { |
397 |
+ |
final ReentrantLock lock = this.lock; |
398 |
|
lock.lock(); |
399 |
|
try { |
400 |
|
/* |
418 |
|
* @return the number of parties currently blocked in {@link #await} |
419 |
|
**/ |
420 |
|
public int getNumberWaiting() { |
421 |
+ |
final ReentrantLock lock = this.lock; |
422 |
|
lock.lock(); |
423 |
|
try { |
424 |
|
return parties - count; |