Book Image

Learning Concurrent Programming in Scala

By : Aleksandar Prokopec
5 (1)
Book Image

Learning Concurrent Programming in Scala

5 (1)
By: Aleksandar Prokopec

Overview of this book

Table of Contents (18 chapters)
Learning Concurrent Programming in Scala
About the Author
About the Reviewers


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 of this operation with the p parameter.

  3. Implement a program that renders the Mandelbrot set in parallel.

  4. Implement a program that simulates a cellular automaton in parallel.

  5. Implement a parallel Barnes-Hut N-body simulation algorithm.

  6. Explain how you can...