import java.util.concurrent.CancellationException;
import java.util.concurrent.CompletableFuture;
// The main method must be in a class named "Main".
class Main {
public static void main(String[] args) {
CompletableFuture<?> f = CompletableFuture.supplyAsync(() -> false);
f.cancel(true);
try {
f.join();
} catch (CancellationException e) {
System.out.println("CancellationException was thrown at call to f.join()");
e.printStackTrace(System.out);
}
}
}
To embed this program on your website, copy the following code and paste it into your website's HTML: