Java tutorial
//package com.java2s; //License from project: Apache License import java.util.concurrent.Future; public class Main { private static boolean cancel(final Future<?> future) { return future.isDone() || future.isCancelled() || future.cancel(true); } public static boolean cancel(final Future<?> future, final boolean mayInterruptIfRunning) { return (future != null) && future.cancel(mayInterruptIfRunning); } public static boolean isDone(final Future<?> future) { return (future != null) && future.isDone(); } public static boolean isCancelled(final Future<?> future) { return (future != null) && future.isCancelled(); } }