Caveats with parallel collections

Parallel collections were designed to provide a programming API similar to sequential Scala collections. Every sequential collection has a parallel counterpart and most operations have the same signature in both sequential and parallel collections. Still, there are some caveats when using parallel collections, and we will study them in this section.

Non-parallelizable collections

Parallel collections use splitters, represented with the Splitter[T] type, in order to provide parallel operations. A splitter is a more advanced form of an iterator; in addition to the iterator's next and hasNext methods, splitters define the split method, which divides the splitter S into a sequence of splitters that traverse parts of ...

Get Learning Concurrent Programming in Scala - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.