mirror of
https://github.com/plan-player-analytics/Plan.git
synced 2024-11-08 03:39:42 +01:00
Prevented synchronization issue with UnitSemaphoreAccessLock
Using the boolean outside of the synchronized block might have caused issues.
This commit is contained in:
parent
2c9c691b4f
commit
5c01cde102
@ -35,20 +35,20 @@ public class UnitSemaphoreAccessLock {
|
|||||||
|
|
||||||
public void enter() {
|
public void enter() {
|
||||||
try {
|
try {
|
||||||
if (accessing.get()) {
|
|
||||||
synchronized (lockObject) {
|
synchronized (lockObject) {
|
||||||
|
if (accessing.get()) {
|
||||||
lockObject.wait();
|
lockObject.wait();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
accessing.set(true);
|
accessing.set(true);
|
||||||
|
}
|
||||||
} catch (InterruptedException e) {
|
} catch (InterruptedException e) {
|
||||||
Thread.currentThread().interrupt();
|
Thread.currentThread().interrupt();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void exit() {
|
public void exit() {
|
||||||
accessing.set(false);
|
|
||||||
synchronized (lockObject) {
|
synchronized (lockObject) {
|
||||||
|
accessing.set(false);
|
||||||
lockObject.notify();
|
lockObject.notify();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user