Fixed reentrant locking mechanism for PoorMansLock
This commit is contained in:
@@ -27,8 +27,10 @@ public class PoorMansLock {
|
||||
}
|
||||
|
||||
public synchronized void lock() {
|
||||
if (owner != null && owner != Thread.currentThread()) {
|
||||
// ToDo: do we need to await for unlock?
|
||||
if(owner == Thread.currentThread())
|
||||
return;
|
||||
|
||||
if (owner != null) {
|
||||
throw new RuntimeException("Unable to lock this resource: already in use");
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user