this.rLock = rLock;
this.wLock = null;
}
- public LockHolder(Lock rLock, Lock wLock) {
+ LockHolder(Lock rLock, Lock wLock) {
this.rLock = rLock;
this.wLock = wLock;
}
@Override
public void close() {
- if (wLock != null) wLock.unlock();
- if (rLock != null) rLock.unlock();
+ if (wLock != null) { wLock.unlock(); wLock = null; }
+ if (rLock != null) { rLock.unlock(); rLock = null; }
}
public void downgrade() {
if (rLock == null) throw new IllegalStateException("no locks are held");