What is the difference between invokeAll and submit in ExecutorService?

invokeAll

<T> List<Future<T>> invokeAll(Collection<? extends Callable<T>> tasks)
Executes the given tasks, returning a list of Futures holding their status and results when all complete.

<T> List<Future<T>> invokeAll(Collection<? extends Callable<T>> tasks, long timeout, TimeUnit unit)
Executes the given tasks, returning a list of Futures holding their status and results when all complete or the timeout expires, whichever happens first.

submit

<T> Future<T> submit(Callable<T> task)
Submits a value-returning task for execution and returns a Future representing the pending results of the task.

Future<?> submit(Runnable task)
Submits a Runnable task for execution and returns a Future representing that task.

<T> Future<T> submit(Runnable task, T result)
Submits a Runnable task for execution and returns a Future representing that task.

Comments

Popular posts from this blog

Spring Elasticsearch Operations

Network Error and Timeout on Authorize.net JS

Object oriented programming concepts (OOPs)