From 8fd30ea15d6344e0bbc4a614aacdfc49d69749b8 Mon Sep 17 00:00:00 2001 From: TudbuT Date: Tue, 25 Jun 2024 05:22:22 +0200 Subject: [PATCH] fix lock not waiting --- src/main/java/de/tudbut/tools/Lock.java | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/src/main/java/de/tudbut/tools/Lock.java b/src/main/java/de/tudbut/tools/Lock.java index 5622171..968b563 100644 --- a/src/main/java/de/tudbut/tools/Lock.java +++ b/src/main/java/de/tudbut/tools/Lock.java @@ -57,21 +57,22 @@ public class Lock extends SimpleLock { */ public synchronized void waitHere() { if(!isTimed) { - while(relocking) + do super.waitHere(); + while(relocking); return; } if(!super.isLocked()) return; - while(relocking) { + do { long wt = timeLeft0(); if(wt == 0) { unlock(); return; } super.waitHere(wt); - } + } while(relocking); } /** @@ -83,19 +84,19 @@ public class Lock extends SimpleLock { return; long start = System.currentTimeMillis(); if(!isTimed) { - while(relocking) { + do { long sectionOffset = System.currentTimeMillis() - start; long wt = timeout - sectionOffset; if(wt == 0) break; super.waitHere(wt); - } + } while(relocking); return; } if(!super.isLocked()) return; - while(relocking) { + do { long wt = timeLeft0(); if(wt == 0) { unlock(); @@ -106,7 +107,7 @@ public class Lock extends SimpleLock { if(wt == 0) break; super.waitHere(wt); - } + } while(relocking); } /**