O'Reilly logo

Java 9 Cookbook by Nick Samoylov, Mohamed Sanaulla

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 to do it...

All computations are encapsulated inside a subclass of one of the two subclasses (RecursiveAction or RecursiveTask<T>of the abstract ForkJoinTask class. You can extend either RecursiveAction (and implement the void compute() method) or RecursiveTask<T> (and implement the T compute() method). As you may have probably noticed, you can choose to extend the RecursiveAction class for tasks that do not return any value, and extend RecursiveTask<T> when you need your tasks to return a value. In our demo, we are going to use the latter because it is slightly more complex.

Let's say we would like to calculate the average speed of traffic in a certain location on a certain date and time and driving conditions (all these parameters ...

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