Skip to content

Instantly share code, notes, and snippets.

@claudioaltamura
Created November 23, 2018 05:15
Show Gist options
  • Save claudioaltamura/dac3f56e41a77a052c59539cc06fb52e to your computer and use it in GitHub Desktop.
Save claudioaltamura/dac3f56e41a77a052c59539cc06fb52e to your computer and use it in GitHub Desktop.
Create a generic array with toArray() and Array.newInstance
Map<String, CompletableFuture<JsonNode>> completableFutures =
this.createCompletableFutures(myRequest);
Collection<CompletableFuture<JsonNode>> values = completableFutures.values();
CompletableFuture<JsonNode>[] completableFuturesArray =
values.toArray((CompletableFuture<JsonNode>[])Array.newInstance(CompletableFuture.class,completableFutures.size()));
CompletableFuture<Void> combinedFutures = CompletableFuture.allOf(completableFuturesArray);
combinedFutures.get(100, TimeUnit.MILLISECONDS);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment