/** * Schedules the task for execution with the contained timeout. If a task is already pending or running, it will be * cancelled (not interrupted). The new task will be scheduled to run in now + timeout. * * @return <code>true</code> if the schedule was successful, <code>false</code> otherwise. */ public boolean schedule() { ScheduledFuture<?> currentTask = cancelCurrentTask(); if (m_executor.isShutdown()) { // We cannot submit any new tasks... return false; } ScheduledFuture<?> newTask = m_executor.schedule(m_task, m_timeout, m_timeUnit); m_futureRef.compareAndSet(currentTask, newTask); return true; }