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

The Treacherous Paths to Concurrency

A quick look at the Activity Monitor on my system shows that while one core is super busy running the code, the other cores are sitting around sipping iced tea. Since this program is I/O intensive, we can get better performance if we throw a few threads at the problem and make use of those other cores.

Put on your Java hat for a minute and think about ways to make the code faster. The mere thought of using the JDK concurrency library can be quite nerve-wracking. Starting threads is not really hard, only clumsy—you’d use the executors to create a pool for threads. You can schedule exploring different subdirectories to threads from the pool. But the problem stems from the two variables—the shared mutable variables. ...

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