Java Thread Future cancel(final Future future)

Here you can find the source of cancel(final Future future)

Description

cancel

License

Apache License

Declaration

private static boolean cancel(final Future<?> future) 

Method Source Code

//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);
    }/*w  w w. jav a 2s  . c  o  m*/

    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();
    }
}

Related

  1. callback(final CountDownLatch latch)
  2. cancel(Future toCancel)
  3. cancel(List> futures)
  4. cancelNullableFutures(boolean mayInterruptIfRunning, Iterable> futures)
  5. cancelScheduledFuture(ScheduledFuture scheduledFuture)