Chapter 19
Concurrency in Scala

by Venkat Subramaniam

We’ve seen the object-oriented paradigm and the functional style of programming interplay in Scala in the previous Scala chapters. In this chapter, we’ll use the functional purity for greater good—programming concurrency.

We all desire to make our applications faster and more responsive. There’s no shortage of resources with multiple cores in our hands. The hard part is writing the code correctly to reap the benefits of the power on hand.

To fully exploit the power of concurrency and perform various complex tasks, concurrency libraries like Akka[19] are quite helpful. (See also Programming Concurrency on the JVM [Sub11] by one of our favorite authors -ed.) However, in this chapter, we’ll stay within the facilities provided directly in the Scala language and make use of parallel collections.