Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Groovy (GPars) and MissingMethodException when calling eachParallel()

When I run the following code in the console (groovy 2.1.3):

strings =  [ "butter", "bread", "dragon", "table" ]
strings.eachParallel{println "$it0"}

I get:

groovy.lang.MissingMethodException: No signature of method: java.util.ArrayList.eachParallel() is applicable for argument types: (ConsoleScript40$_run_closure1) values: [ConsoleScript40$_run_closure1@a826f5]

Anyone can tell me what I am doing wrong?

like image 491
Armin Avatar asked Jun 04 '13 23:06

Armin


1 Answers

I think you are missing the set up. Try

@Grab(group='org.codehaus.gpars', module='gpars', version='1.0.0')
import groovyx.gpars.GParsPool

GParsPool.withPool {
    def strings =  [ "butter", "bread", "dragon", "table" ]
    strings.eachParallel { println it }
}
like image 128
Michael Rutherfurd Avatar answered Nov 13 '22 04:11

Michael Rutherfurd