public void checkTasks(long now) { if (slots[SLOTS] == null && now < nextTick) { return; } synchronized (this) { queueTasks(SLOTS, 0); for (int i = 0; now >= nextTick; i++, nextTick += TICK) { if (i < 3) { if (++currSlot >= SLOTS) { currSlot = 0; currIter++; } queueTasks(currSlot, currIter); } } } while (!queue.isEmpty()) { Task task = (Task) queue.dequeue(); task.perform(); } } }