From e2b6b7b2df6757345a0e70628ea9090d17b16477 Mon Sep 17 00:00:00 2001 From: Steve Hannah Date: Fri, 6 Feb 2015 17:07:01 -0800 Subject: [PATCH] Fixed monitorExit to work with more than one enter/exit. --- .../main/java/org/teavm/classlib/java/lang/TObject.java | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) 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(); + } } }