Executors.invokeAny

Executes the given tasks, returning the result of one that has completed successfully (i.e., without throwing an exception), if any do. Upon normal or exceptional return, tasks that have not completed are cancelled. The results of this method are undefined if the given collection is modified while this operation is in progress.

@param tasks the collection of tasks @param (T) the type of the values returned from the tasks @return the result returned by one of the tasks @throws InterruptedException if interrupted while waiting @throws NullPointerException if tasks or any element task subject to execution is {@code null} @throws IllegalArgumentException if tasks is empty @throws ExecutionException if no task successfully completes @throws RejectedExecutionException if tasks cannot be scheduled for execution

  1. T invokeAny(ExecutorService es, Collection!(Callable!(T)) tasks)
    class Executors
    static
    T
    invokeAny
    (
    T
    )
    (,
    Collection!(Callable!(T)) tasks
    )
  2. T invokeAny(ExecutorService es, Collection!(Callable!(T)) tasks, Duration timeout)

Meta