Skip to content

Instantly share code, notes, and snippets.

@babjo
Created November 27, 2017 15:06
Show Gist options
  • Save babjo/c37631feb9e3ce665315a9f059f93c95 to your computer and use it in GitHub Desktop.
Save babjo/c37631feb9e3ce665315a9f059f93c95 to your computer and use it in GitHub Desktop.
CompletableFuture<String> future1
= CompletableFuture.supplyAsync(() -> "Hello");
CompletableFuture<String> future2
= CompletableFuture.supplyAsync(() -> "Beautiful");
CompletableFuture<String> future3
= CompletableFuture.supplyAsync(() -> "World");
CompletableFuture<Void> combinedFuture
= CompletableFuture.allOf(future1, future2, future3);
// ...
combinedFuture.get();
assertTrue(future1.isDone());
assertTrue(future2.isDone());
assertTrue(future3.isDone());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment