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 the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.