调用eachParallel()时的Groovy(GPars)和MissingMethodException [英] Groovy (GPars) and MissingMethodException when calling eachParallel()

查看:120
本文介绍了调用eachParallel()时的Groovy(GPars)和MissingMethodException的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

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

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

我得到:

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?

推荐答案

我认为您缺少该设置.试试

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 }
}

这篇关于调用eachParallel()时的Groovy(GPars)和MissingMethodException的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆