From 8ffa1acfbc135bf309d0ec5b935b7d9dd6427bb8 Mon Sep 17 00:00:00 2001 From: Tuukka Lehtonen Date: Mon, 12 Nov 2018 14:35:16 +0200 Subject: [PATCH] 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 --- .../simantics/simulator/toolkit/DynamicExperimentThread.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) 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) { -- 2.47.1