Fixed reentrant locking mechanism for PoorMansLock
This commit is contained in:
@@ -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");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user