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