假设 Groovy/Gpars 中的以下并行过程......
def result
GParsPool.withPool(5){
result = idList.collectParallel{processItem(it)}
}
ifresult只是一个数组列表,并且假设没有线程访问或操作resultin processItem(),是否result需要显式同步?我需要知道我是否应该这样做...
def result = Collections.synchronizedList( new ArrayList())
GParsPool.withPool(5){
result = idList.collectParallel{processItem(it)}
}