调用eachParallel()时的Groovy(GPars)和MissingMethodException

Arm*_*min 7 groovy missingmethodexception gpars

当我在控制台中运行以下代码时(groovy 2.1.3):

strings =  [ "butter", "bread", "dragon", "table" ]
strings.eachParallel{println "$it0"}
Run Code Online (Sandbox Code Playgroud)

我明白了:

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

谁能告诉我我做错了什么?

Mic*_*urd 10

我想你错过了设置.尝试

@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 }
}
Run Code Online (Sandbox Code Playgroud)