/** * Cancels the specified task if it has not run or is not running. * * @param taskRef task reference */ private void cancelTask(AtomicReference<TimerTask> taskRef) { swapAndCancelTask(taskRef, null); }
/** * Reschedules the specified task, cancelling existing one if applicable. * * @param taskRef task reference * @param millis delay in milliseconds */ private void rescheduleTask(AtomicReference<TimerTask> taskRef, long millis) { ProcessorTask newTask = new ProcessorTask(); timer.schedule(newTask, millis); swapAndCancelTask(taskRef, newTask); }