http://www.docjar.com/html/api/java/util/concurrent/ArrayBlocki
public boolean offer(E e) {
if (e == null) throw new NullPointerException();
// why it makes a reference to the lock here?
final ReentrantLock lock = this.lock;
lock.lock();
try {
if (count == items.length)
return false;
else {
insert(e);
return true;
}
} finally {
lock.unlock();
}
}
final ReentrantLock lock = this.lock; 有什么特殊的地方?我什么不能直接用this
.lock,而要绕一下呢?
b***k 发帖数: 77
2
This is not syntax question.
This is multi-threading problem.As far as I can see making a reference to
this.lock is to make sure lock and unlock are performed on the same lock.