O'Reilly logo

Java 9 Concurrency Cookbook - Second Edition by Javier Fernández González

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

How it works...

In this recipe, you learned how to send a list of tasks to an executor and wait for the finalization of all of them using the invokeAll() method. This method receives a list of Callable objects and returns a list of Future objects. This list will have a Future object per task. The first object in the list of Future objects will be the object that controls the first task in the list of Callable objects, the second object the second task, and so on.

The first point to take into consideration is that the type of data used for the parameterization of the Future interface in the declaration of the list that stores the result objects must be compatible with the one used to parameterize Callable objects. In this case, you used the ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required