return;
}
synchronized (this) {
log.debug("executing scheduler");
TimedTask task;
for (Iterator<TimedTask> iter = tasks.iterator(); iter.hasNext();) {
if ((task = iter.next()).runIfDue(n = currentTimeMillis())) {
if (task.nextRuntime() == -1) {
// if the next runtime is -1, that means this event
// is never scheduled to run again, so we remove it.
iter.remove();
} else {
// set the nextRuntime to the nextRuntim of this event
nextRunTime = task.nextRuntime();
}
} else if (task.nextRuntime() == -1) {
// this event is not scheduled to run.
iter.remove();
} else if (nextRunTime == 0 || task.nextRuntime() < nextRunTime) {
// this event occurs before the current nextRuntime,
// so we update nextRuntime.
nextRunTime = task.nextRuntime();
} else if (n > task.nextRuntime()) {
// Since the scheduled events are in the order of soonest to
// latest, we now know that all further events are in the future
// and we can therefore stop iterating.
return;
}