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

2024-03-07

当我在控制台中运行以下代码时(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]

任何人都可以告诉我我做错了什么?


我认为你错过了设置。尝试

@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 }
}
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

调用eachParallel() 时的 Groovy (GPars) 和 MissingMethodException 的相关文章

随机推荐