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. ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access