Skip to content

Instantly share code, notes, and snippets.

@snackycracky
Created June 24, 2011 09:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save snackycracky/1044478 to your computer and use it in GitHub Desktop.
Save snackycracky/1044478 to your computer and use it in GitHub Desktop.
Step 3 - Experiment with parallel collection processing
@Grab(group='org.codehaus.gpars', module='gpars', version='0.11')
import groovyx.gpars.GParsPool
def x,y
GParsPool.withPool {
def animals = ['dog', 'ant', 'cat', 'whale']
x = animals.anyParallel {it ==~ /ant/} ? 'Found an ant' : 'No ants found'
y = animals.everyParallel {it.contains('a')} ? 'All animals contain a' : 'Some animals can live without an a'
}
println x
println y
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment