Skip to content

Instantly share code, notes, and snippets.

@ova2
Last active May 22, 2021 14:52
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 ova2/9c2ee96de4d7ca2327b163df7d2989f0 to your computer and use it in GitHub Desktop.
Save ova2/9c2ee96de4d7ca2327b163df7d2989f0 to your computer and use it in GitHub Desktop.
CompletableFuture<Void> cf = CompletableFuture.supplyAsync(() -> 1 + 2)
.thenApply(i -> "1 + 2 = " + i)
.thenAccept(s -> System.out.println("Computation result: " + s))
.thenRun(() -> System.out.println("Finished"));
cf.get();
// Output
Computation result: 1 + 2 = 3
Finished
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment