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 3e6bfb01e..65776b5b8 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 @@ -196,7 +196,6 @@ public class TObject { if (!holdsLock(this)) { throw new TIllegalMonitorStateException(); } - TThread thread = TThread.currentThread(); PlatformQueue listeners = monitor.notifyListeners; while (!listeners.isEmpty()) { NotifyListener listener = listeners.remove(); @@ -205,7 +204,6 @@ public class TObject { break; } } - TThread.setCurrentThread(thread); } @Sync @@ -256,6 +254,7 @@ public class TObject { final TThread currentThread = TThread.currentThread(); int timerId = -1; boolean expired; + boolean performed; int lockCount; public NotifyListenerImpl(TObject obj, AsyncCallback callback, int lockCount) { @@ -280,6 +279,10 @@ public class TObject { @Override public void run() { + if (performed) { + return; + } + performed = true; if (timerId >= 0) { Platform.killSchedule(timerId); timerId = -1; diff --git a/teavm-core/src/main/resources/org/teavm/javascript/runtime.js b/teavm-core/src/main/resources/org/teavm/javascript/runtime.js index 4a7dd2c94..c0d860e59 100644 --- a/teavm-core/src/main/resources/org/teavm/javascript/runtime.js +++ b/teavm-core/src/main/resources/org/teavm/javascript/runtime.js @@ -497,7 +497,11 @@ function $rt_continue(f) { var self = this; var args = arguments; var thread = $rt_getThread(); + var oldPostponed = thread.postponed; thread.postponed = function() { + if (oldPostponed) { + oldPostponed(); + } f.apply(self, args); }; };