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 = ...

Get Pragmatic 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.