- nextExecSimulTime.set(current + sleepTime);
- if (sleepTime > 0)
- Thread.sleep(sleepTime);
- }
- catch (@SuppressWarnings("unused") InterruptedException e)
- {// do nothing; it is normal execution flow to be interrupted
+ // always execute to keep timeline from "hanging behind" for too long
+ long current = System.currentTimeMillis();
+ timeline.executeUntil(timeline.laterThan(current), current + 10);
+ long sleepTime;
+ if (timeline.hasNext())
+ sleepTime = timeline.nextEventTime() - current;
+ else
+ sleepTime = 10000;
+ try
+ {
+ nextExecSimulTime.set(current + sleepTime);
+ if (sleepTime > 0)
+ Thread.sleep(sleepTime);
+ }
+ catch (@SuppressWarnings("unused") InterruptedException e)
+ {// do nothing; it is normal execution flow to be interrupted
+ }