Fixes the lock

This commit is contained in:
Sotr
2018-08-13 04:59:13 +08:00
parent 4eac44c8df
commit 75ab6a414c

View File

@@ -31,7 +31,7 @@ public class ReentrantSpinningLock {
public void unlock() {
if (reentrantLocks == 0) {
heldThreadId = 0;
if (readerThreads.getAndDecrement() == 1) { // Micro-optimization: this saves one subtract
if (readerThreads.get() == 0 || readerThreads.getAndDecrement() == 1) { // Micro-optimization: this saves one subtract
writeLocked.set(false);
}
} else {