Skip to content

Instantly share code, notes, and snippets.

@babjo
Created November 26, 2017 03:31
Show Gist options
  • Save babjo/94b420287dc01f1bfd3869b456b7f91f to your computer and use it in GitHub Desktop.
Save babjo/94b420287dc01f1bfd3869b456b7f91f to your computer and use it in GitHub Desktop.
public Future<String> calculateAsync() throws InterruptedException {
CompletableFuture<String> completableFuture = new CompletableFuture<>();
Executors.newCachedThreadPool().submit(() -> {
Thread.sleep(500);
completableFuture.complete("Hello");
return null;
});
return completableFuture;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment