Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
private static void demoCompletableFutureComplete() throws InterruptedException, ExecutionException {
CompletableFuture<String> completableFuture = new CompletableFuture<>();
//String value = completableFuture.get();
//The above statement will cause program to run forever.
// Because there is nothing for the completable future to do.
completableFuture.complete("Completing the completable future with this default text");
String value = completableFuture.get();
System.out.println("Value After Complete: "+value);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment