Archived
0

Fixed reentrant locking mechanism for PoorMansLock

This commit is contained in:
Daniil
2018-08-05 13:15:31 +07:00
parent afe88e260c
commit b5a7942b67

View File

@@ -27,8 +27,10 @@ public class PoorMansLock {
} }
public synchronized void lock() { public synchronized void lock() {
if (owner != null && owner != Thread.currentThread()) { if(owner == Thread.currentThread())
// ToDo: do we need to await for unlock? return;
if (owner != null) {
throw new RuntimeException("Unable to lock this resource: already in use"); throw new RuntimeException("Unable to lock this resource: already in use");
} }