我在这里找到了这个例子数据并行
GParsPool.withPool() {
Closure longLastingCalculation = {calculate()}
Closure fastCalculation = longLastingCalculation.async()
Future result=fastCalculation()
//do stuff while calculation performs …
println result.get()
}
我觉得它有点广泛。有没有办法缩短它?
也许:
GParsPool.withPool() {
Future result = calculate().async()
//do stuff while calculation performs …
println result.get()
}
那行得通吗?
如果没有,还有其他方法吗?