Skip to content

Instantly share code, notes, and snippets.

@wkdalsgh192
Created July 16, 2021 10:53
Show Gist options
  • Save wkdalsgh192/99c7eeb7e3ddfb6bfd3cb5453efdfbb3 to your computer and use it in GitHub Desktop.
Save wkdalsgh192/99c7eeb7e3ddfb6bfd3cb5453efdfbb3 to your computer and use it in GitHub Desktop.
// Using a callback method
CompletableFuture<String> future4 = CompletableFuture.supplyAsync(() -> {
System.out.println("Hello "+ Thread.currentThread().getName());
return "Hello";
}).thenApply((s) -> { // thenApply, thenAccept or thenRun can also be used here
System.out.println(Thread.currentThread().getName());
return s.toUpperCase(Locale.ROOT);
});
System.out.println(future4.get());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment