How to do it...

Follow these steps to implement the example:

  1. Create a class named FolderProcessor and specify that it extends the CountedCompleter class parameterized with the List<String> type:
        public class FolderProcessor extends                                CountedCompleter<List<String>> { 
  1. Declare a private String attribute named path. This attribute will store the full path of the folder the task is going to process:
        private String path; 
  1. Declare a private String attribute named extension. This attribute will store the name of the extension of the files the task is going to look for:
        private String extension; 
  1. Declare two List private attributes named tasks and resultList. We will use the first one to store all the child tasks launched from this task and ...

Get Java 9 Concurrency Cookbook - Second Edition now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.