Skip to content

Instantly share code, notes, and snippets.

@john-nash-rs
Created April 26, 2020 13:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save john-nash-rs/5ae3d313e6934dc04dc27b975de7b7ad to your computer and use it in GitHub Desktop.
Save john-nash-rs/5ae3d313e6934dc04dc27b975de7b7ad to your computer and use it in GitHub Desktop.
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