lHolds.decrement();
assert lHolds.intValue() == -1;
}
public void releaseWriteLock() {
final OModifiableInteger lHolds = lockHolds.get();
if (lHolds.intValue() < -1) {
lHolds.increment();
return;
}
setExclusiveOwnerThread(null);
final WNode node = myNode.get();
node.locked = false;
final Thread waitingWriter = node.waitingWriter;
if (waitingWriter != null)
LockSupport.unpark(waitingWriter);
final Set<Thread> waitingReaders = new HashSet<Thread>();
for (Thread waitingReader : node.waitingReaders) {
if (waitingReaders.add(waitingReader))
LockSupport.unpark(waitingReader);
}
myNode.set(predNode.get());
predNode.set(null);
lHolds.increment();
assert lHolds.intValue() == 0;
}