/** * Attempts to cancel the specified {@link ScheduledTask}. * * @param task the {@link ScheduledTask} to cancel * @return true if the {@link ScheduledTask} was canceled; otherwise, false */ public boolean cancel(T task) { CancellableTask<K, T> cancellableTask = this.cancellableTaskMap.getIfPresent(task.getKey()); if (cancellableTask != null && cancellableTask.getScheduledTask() == task && cancellableTask.cancel()) { this.cancellableTaskMap.invalidate(task.getKey()); return true; } return false; }
/** * Attempts to cancel the specified {@link ScheduledTask}. * * @param task the {@link ScheduledTask} to cancel * @return true if the {@link ScheduledTask} was canceled; otherwise, false */ public boolean cancel(T task) { CancellableTask<K, T> cancellableTask = this.cancellableTaskMap.getIfPresent(task.getKey()); if (cancellableTask != null && cancellableTask.getScheduledTask() == task && cancellableTask.cancel()) { this.cancellableTaskMap.invalidate(task.getKey()); return true; } return false; }