From: Tuukka Lehtonen Date: Mon, 12 Nov 2018 12:35:16 +0000 (+0200) Subject: Wake DynamicExperimentThread task runner up when state changes X-Git-Tag: v1.43.0~136^2~281 X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=commitdiff_plain;h=refs%2Fchanges%2F53%2F2453%2F2;p=simantics%2Fplatform.git Wake DynamicExperimentThread task runner up when state changes Prevents the thread from getting stuck when it is shut down from stopped state. gitlab #194 Change-Id: Iaf5ad6238aae8925c42d029078ea5f2a2ffa3e8c --- diff --git a/bundles/org.simantics.simulator.toolkit/src/org/simantics/simulator/toolkit/DynamicExperimentThread.java b/bundles/org.simantics.simulator.toolkit/src/org/simantics/simulator/toolkit/DynamicExperimentThread.java index 9ee57f510..bff9fe751 100644 --- a/bundles/org.simantics.simulator.toolkit/src/org/simantics/simulator/toolkit/DynamicExperimentThread.java +++ b/bundles/org.simantics.simulator.toolkit/src/org/simantics/simulator/toolkit/DynamicExperimentThread.java @@ -190,7 +190,7 @@ abstract public class DynamicExperimentThread extends Thread { }; public int runTasks() { - ArrayList todo = new ArrayList<>(); + ArrayList todo = new ArrayList<>(tasks.size()); synchronized(tasks) { todo.addAll(tasks); tasks.clear(); @@ -273,6 +273,9 @@ abstract public class DynamicExperimentThread extends Thread { public void changeState(ExperimentState state) { this.state = state; fireStateChanged(state); + synchronized (tasks) { + tasks.notifyAll(); + } } public void addListener(DynamicExperimentThreadListener listener) {