O'Reilly logo

Mastering Concurrency Programming with Java 9 - Second Edition by Javier Fernández González

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

Concurrent version

There are different ways to parallelize this algorithm. For example:

  • You can create an execution thread per directory we want to process.
  • You can divide the directory tree into groups and create an execution thread per group. The number of groups you create will determine the number of execution threads your application will use.
  • You can use as many threads as cores that are available to the JVM.

In this case, we have to take into account that our algorithm will use intensive I/O operations. Only one thread can read the disk at a time, so not all solutions will increase the performance of the serial version of the algorithm.

We will use the last option to implement our concurrent version. We will store the directories ...

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