Processing collections concurrently
As mentioned in the introduction, this chapter's recipes will recourse to the spectacular features of the GPars framework.
In this recipe, we take a look at the Parallelizer
, which is the common GPars term that refers to Parallel Collections. These are a number of additional methods added by GPars to the Groovy collection framework, which enable data parallelism techniques.
Getting ready
We will start with setting up the Gradle build (see the Integrating Groovy into the build process using Gradle recipe in Chapter 2, Using Groovy Ecosystem) and the folder structure that we will reuse across the recipes of this chapter. In a new folder aptly called parallel
, create a build.gradle
file having the following content:
apply plugin: 'groovy' repositories { mavenCentral() } dependencies { compile 'org.codehaus.groovy:groovy-all:2.1.6' compile 'org.codehaus.gpars:gpars:1.0.0' compile 'com.google.guava:guava:14.0.1' compile group: 'org.codehaus.groovy.modules...