diff --git a/teavm-classlib/src/main/java/org/teavm/classlib/java/lang/TObject.java b/teavm-classlib/src/main/java/org/teavm/classlib/java/lang/TObject.java index a343528ed..9ca2ef4e4 100644 --- a/teavm-classlib/src/main/java/org/teavm/classlib/java/lang/TObject.java +++ b/teavm-classlib/src/main/java/org/teavm/classlib/java/lang/TObject.java @@ -51,10 +51,13 @@ public class TObject { } static void monitorExit(TObject o){ - o.owner = null; + o.monitorCount--; - if ( o.monitorLock != null ){ - o.monitorLock.notifyAll(); + if ( o.monitorCount == 0 ){ + if ( o.monitorLock != null ){ + o.owner = null; + o.monitorLock.notifyAll(); + } } }