Parallel Collections
If laziness is a road to efficiency, parallelism may be considered a flight to that destination. If two or more tasks can be executed in any sequence without any impact on the correctness of the result, then those tasks may very well be run in parallel. Scala provides a few different ways to achieve that. The easiest of those is parallel processing of elements in a collection.
We work with collections of data all the time. We may need to check the price of several products, update inventories based on the orders fulfilled, or tally up payments for recent transactions. When we have a collection of data to work with, we often use internal iterators like map, filter, and foldLeft (we used a few of these in Chapter 8, Collections ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access