-
-
Save deepakmehra10/b243f24268fad8504101e40077052c83 to your computer and use it in GitHub Desktop.
This file contains 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
CompletableFuture nameFuture = CompletableFuture.supplyAsync(() -> "Deepak"); | |
CompletableFuture nameFutureCopy = nameFuture.copy(); | |
CompletableFuture withSurname = nameFuture.thenApply(name -> "Deepak Mehra"); | |
// Should be avoided, only for demonstration purpose | |
System.out.println(withSurname.join()); | |
// Change in original instance should affect it's copy instance. | |
System.out.println(nameFutureCopy.join()); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment