Skip to content

Instantly share code, notes, and snippets.

@vichu
Last active March 29, 2019 04:00
Show Gist options
  • Save vichu/274f397aa6dfb0fecad95cc70ebb6088 to your computer and use it in GitHub Desktop.
Save vichu/274f397aa6dfb0fecad95cc70ebb6088 to your computer and use it in GitHub Desktop.
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