Executors.invokeAny

Executes the given tasks, returning the result of one that has completed successfully (i.e., without throwing an exception), if any do before the given timeout elapses. 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 timeout the maximum time to wait @param unit the time unit of the timeout argument @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 unit, or any element task subject to execution is {@code null} @throws TimeoutException if the given timeout elapses before any task successfully completes @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)
  2. T invokeAny(ExecutorService es, Collection!(Callable!(T)) tasks, Duration timeout)
    class Executors
    static
    T
    invokeAny
    (
    T
    )
    (,
    Collection!(Callable!(T)) tasks
    ,
    Duration timeout
    )

Meta