isJobAdded = false;
// check if the next timer should fire before the normal sleep time is over
Date duedate = new Date(SimulationRunContext.getClock().getCurrentTime().getTime() + millisToWait);
List<TimerEntity> nextTimers = commandExecutor.execute(new GetUnlockedTimersByDuedateCmd(duedate, new Page(0, 1)));
if (!nextTimers.isEmpty()) {
long millisTillNextTimer = nextTimers.get(0).getDuedate().getTime() - SimulationRunContext.getClock().getCurrentTime().getTime();
if (millisTillNextTimer < millisToWait && millisTillNextTimer != 0) {
millisToWait = millisTillNextTimer;