Exercises

In the following exercises, you will use data-parallel collections in several concrete parallel collection use cases, and implement custom parallel collections. In all examples, a special emphasis is put on measuring the performance gains from parallelization. Even when it is not asked for 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 for 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 of this ...

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.