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 ...

Get Mastering Concurrency Programming with Java 9 - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.