Exercises

In the following exercises, you will use data-parallel collections in several concrete parallel collection use cases, as well as implement custom parallel collections. In all examples, a particular emphasis is put on measuring the performance gains from parallelization. Even when it is not asked explicitly, you should ensure that your program is not only correct, but also faster than a corresponding sequential program.

  1. Measure the average running time of allocating a simple object on the JVM.
  2. Count the occurrences of the whitespace character in a randomly generated string, where the probability of a whitespace at each position is determined by a p parameter. Use the parallel foreach method. Plot a graph that correlates the running time ...

Get Learning Concurrent Programming in Scala 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.