, . , . .
, , result, / for.
def intersection(a: GenSet[Int], b: GenSet[Int]): Set[Int] = {
val result = mutable.Set[Int]() //This field is not thread safe.
for (x <- a) if (b contains x) result += x //mutation occured here.
result
}
, : intersection((0 until 1000).toSet, (0 until 1000 by 4).toSet). Set 0 to 1000. , for loop, , . x 0 till 1000. , .
intersection((0 until 1000).par.toSet, (0 until 1000 by 4).par.toSet). , , Parallel set. , for loop, / . , < , , , , . , , , .
, concurrency:
" ".