Timeout while waiting for a batch of Futures to complete?
问题 I have a set of Futures created by submitting Callable s to an Executor . Pseudo code: for all tasks futures.add(executor.submit(new callable(task))) Now I'd like to get all futures waiting at most n seconds until all complete. I know I can call Future#get(timeout) but if I call that sequentially for all my futures in a loop the timouts start adding up. Pseudo code: for all futures future.get(timeout) get blocks with a timeout until the result is ready. Therefore, if the first completes just