/** * 执行给定任务列表,并当所有任务都执行完毕后,返回Future对象列表 * @param tasks 提交的任务列表 * @return a list of Futures representing the tasks, in the same sequential order as produced by the iterator for the * given task list, each of which has completed */ <T> List<Future<T>> invokeAll(Collection<? extends Callable<T>> tasks) throws InterruptedException;
/** * 执行给定任务列表,并当所有任务都执行完毕后,返回Future对象列表 * 如果超时,还没有执行完毕的任务会被取消 * @param tasks 提交的任务列表 * @return a list of Futures representing the tasks, in the same sequential order as produced by the iterator for the * given task list. If the operation did not time out, each task will have completed. If it did time out, some * of these tasks will not have completed. */ T> List<Future<T>> invokeAll(Collection<? extends Callable<T>> tasks, long timeout, TimeUnit unit) throws InterruptedException;
/** * 执行给定任务列表,并当其中一个任务执行完毕后,返回Future对象 * @param tasks 提交的任务列表 * @return the result returned by one of the tasks */ <T> T invokeAny(Collection<? extends Callable<T>> tasks)throws InterruptedException, ExecutionException;
/** * 执行给定任务列表,并当其中一个任务执行完毕后,返回Future对象 * 如果超时,抛出TimeoutException * @param tasks 提交的任务列表 * @return the result returned by one of the tasks */ <T> T invokeAny(Collection<? extends Callable<T>> tasks, long timeout, TimeUnit unit) throws InterruptedException, ExecutionException, TimeoutException;