Created
June 24, 2011 09:17
-
-
Save snackycracky/1044478 to your computer and use it in GitHub Desktop.
Step 3 - Experiment with parallel collection processing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@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