O'Reilly logo

Mastering Concurrency Programming with Java 9 - 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

Data parallelism

In this section, we're going to include all the elements provided by the Groovy programming language to process data structures in a concurrent way. The first element we have to consider is the GParsPool class. This class is an implementation of the JSR-166y based on the fork/join framework that gives us a very good performance to process data structures in a concurrent way.

Let's see an example of how we can use the GParsPool class. First, we have to include the necessary import sentences. Then, create a class name Example2 with a main() method:

import groovyx.gpars.GParsPool 
import static groovyx.gpars.GParsPool.withPool 
class Example2 { 
  static main(args) { 

Then, declare a range of number between one and 1000 and use 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