これらのサンプル文字列のそれぞれで多くのことを行い、ここで他のタイプのObject Integers、後でいくつかのより大きなクラスオブジェクトを返したいと思います。
この例では、単純なことを試みていますが、完全に間違った結果が得られます。少なくとも私が取り戻したいと思っていたものについては。xD
私は取得したいと思っていました:[6, 5, 6, 5]
しかし、代わりに私は取得します:[butter, bread, dragon, table]
package test
@Grab(group='org.codehaus.gpars', module='gpars', version='1.0.0')
import static groovyx.gpars.GParsPool.withPool
class Test {
List<String> strings = new ArrayList<String>([
"butter",
"bread",
"dragon",
"table"
])
def closure = { it.length() }
def doStuff() {
def results = withPool( 4 ) {
strings.eachParallel{ it.length()}
}
println results
}
static main(args) {
def test = new Test()
test.doStuff()
}
}
答えに簡単な説明があればいいのにと思います。どうもありがとう!