Given the code fragment:
Which code fragment invokes all callable objects in the workers set?
workers
ExecutorService.invokeAll(Collection<? extends Callable<T>>) submits every Callable in the given collection for execution and returns a List<Future<T>> once all tasks have completed, which is how all callable objects in a set get invoked and their results retrieved via Future.get(). invokeAny only executes the tasks until one of them completes successfully and returns that single result (not all of them), and ExecutorService.submit() accepts a single Runnable/Callable rather than a collection, so it cannot be used directly on the workers set.
Community Discussion