Fixed race condition in DynamicExperimentThread.
[simantics/platform.git] / bundles / org.simantics.simulator.toolkit / src / org / simantics / simulator / toolkit / DynamicExperimentThread.java
index e3e4f9ba56dad94b8f9de99ac7a868327a67e5e6..0967bfdbc28d19c3e5b69eae0980128fa296ad92 100644 (file)
@@ -151,9 +151,8 @@ abstract public class DynamicExperimentThread extends Thread {
 
                        } else {
 
-                               while(!inState(StandardExperimentStates.Running.class) && inActiveState()) {
-
-                                       synchronized(tasks) {
+                               synchronized(tasks) {
+                                       while(!inState(StandardExperimentStates.Running.class) && inActiveState()) {
                                                int ran = runTasks();
                                                if(ran == 0) {
                                                        try {