Created
July 15, 2021 12:04
-
-
Save wkdalsgh192/c8866e1f61d6f305ef664e12d7506680 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// when there is no return value | |
CompletableFuture<Void> future2 = CompletableFuture.runAsync(() -> { | |
System.out.println("Hello "+ Thread.currentThread().getName()); | |
}); | |
future2.get(); // get() should be called to execute the thread | |
// when there is a return value | |
CompletableFuture<String> future3 = CompletableFuture.supplyAsync(() -> { | |
System.out.println("HEllo " + Thread.currentThread().getName()); | |
return "Hello"; | |
}); | |
System.out.println(future3.get()); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment