if(deltaNs > 0) {
synchronized(tasks) {
- try {
- tasks.wait(deltaMs, deltaNsRem);
- } catch (InterruptedException e) {
- e.printStackTrace();
+ if (inState(StandardExperimentStates.Running.class)) {
+ try {
+ tasks.wait(deltaMs, deltaNsRem);
+ } catch (InterruptedException e) {
+ LOGGER.warn("Dynamic experiment thread '" + this.getName() + "' (" + this.getClass().getName() + ") interrupted", e);
+ }
}
}
}
try {
tasks.wait(Integer.MAX_VALUE);
} catch (InterruptedException e) {
- e.printStackTrace();
+ LOGGER.warn("Dynamic experiment thread '" + this.getName() + "' (" + this.getClass().getName() + ") interrupted", e);
}
}
}
};
public int runTasks() {
- ArrayList<Runnable> todo = new ArrayList<>();
+ ArrayList<Runnable> todo = new ArrayList<>(tasks.size());
synchronized(tasks) {
todo.addAll(tasks);
tasks.clear();
public void changeState(ExperimentState state) {
this.state = state;
fireStateChanged(state);
+ synchronized (tasks) {
+ tasks.notifyAll();
+ }
}
public void addListener(DynamicExperimentThreadListener listener) {