Last active
March 29, 2019 04:00
-
-
Save vichu/274f397aa6dfb0fecad95cc70ebb6088 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
class CompletableFASync { | |
private static CompletableFuture<Integer> doubleMe(final Integer number) { | |
return CompletableFuture.completedFuture(number * 2); | |
} | |
public static void main(String[] args) throws InterruptedException { | |
// Just an example future that returns double of an integer and convert it to String. | |
final CompletionStage<String> processedCompletableFuture = | |
doubleMe(20).thenApply(Object::toString); | |
System.out.println("Main thread name = " + Thread.currentThread()); | |
//Just to make sure that we don't end | |
Thread.sleep(3000); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment