O'Reilly logo

Pragmatic Scala by Venkat Subramaniam

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

A Sequential Time-Consuming Problem

Several applications can benefit from multi-cores and multiple threads: fetching a large volume of data from multiple web services, looking up stock prices, analyzing geological data, and so forth. Instead of getting lost in the details of a complex domain and lengthy code, let’s take a relatively small problem that needs very little code. This will help us focus on key issues and explore possible solutions.

We’ll work with a program that finds the number of files in the subdirectory hierarchy starting with a given directory as the root. Here’s a sequential implementation of the code:

ProgrammingActors/countFilesSequential.scala
 
import​ java.io.File
 
 
def​ getChildren(file: File) = {
 
val​ children = ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required