I'm calling an async client method by streaming over a list of objects. The method returns Future.
What's the best way to iterate over the list of Futures returned after the call (so as to process those Future which comes first)?
Note: The async client only returns Future not CompletableFuture.
Following is the code:
List<Future<Object>> listOfFuture = objectsToProcess.parallelStream()
.map((object) -> {
/* calling an async client returning a Future<Object> */ })
.collect(Collectors.toList());
CompletionService
is quite useless if you don’t have control over the code that produces theFuture
/submits the job to anExecutor
. – Flesher