List futures = new ArrayList(); List accountKeys = Lists.newArrayList(); for(int i = 1 ; i httpCall()); futures.add(future); if(i % 20 == 0){ CompletableFuture.allOf(futures.toArray(new CompletableFuture[0])).join(); accountKeys.addAll(futures.stream().map(CompletableFuture::join).collect(Collectors.toList())); futures = new ArrayList(); } } if(!futures.isEmpty()){ CompletableFuture.allOf(future..