Skip to content

Instantly share code, notes, and snippets.

@jasmine-k
Created March 26, 2018 12:03
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 jasmine-k/5bf65986cd7b0d124d2fb158170c59d1 to your computer and use it in GitHub Desktop.
Save jasmine-k/5bf65986cd7b0d124d2fb158170c59d1 to your computer and use it in GitHub Desktop.
private static void chainOfThenApply() {
CompletableFuture.supplyAsync(() -> {
// Code which might throw an exception
return "Some result";
}).thenApply(result -> {
return "processed result";
}).thenApply(result -> {
return "result after further processing";
}).thenAccept(result -> {
// do something with the final result
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment