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.
Return
the result returned by one of the tasks
Parameters
the collection of tasks
Throws
if interrupted while waiting
if tasks or any element task subject to execution is null
if tasks is empty
if no task successfully completes
if tasks cannot be scheduled for execution
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.
Return
the result returned by one of the tasks
Parameters
the collection of tasks
the maximum time to wait
the time unit of the timeout argument
Throws
if interrupted while waiting
if tasks, or unit, or any element task subject to execution is null
if the given timeout elapses before any task successfully completes
if no task successfully completes
if tasks cannot be scheduled for execution