The following screenshot shows part of an execution of the preceding example:
The key to this example is in the FolderProcessor class. Each task processes the contents of a folder. As you know, this content has the following two kinds of elements:
- Other folders
If the task finds a folder, it creates another FolderProcessor object to process that folder and sends it to the pool using the fork() method. This method sends the task to the pool that will execute it if it has a free worker thread, or it can create a new one. The method returns immediately, so the task can continue processing the contents of the folder. For ...