public Runnable popTask() {
        synchronized (tasks) {
            Iterator<Entry> iter = tasks.iterator();
            if (!iter.hasNext()) {
                return null;
            }
            Entry retEntry = iter.next();
            if (retEntry.getTimestamp() > timer.milliTime()) {
                return null;
            }
            iter.remove();
            return retEntry.getTask();
        }
    }
If there is a task ready for scheduling, remove it from the queue and return it.

@return The next task.
documentapi/src/main/java/com/yahoo/documentapi/messagebus/ScheduledEventQueue.java