How it works...

In this recipe, you implemented a task that increments the elements of an array, using a ForkJoinPool class, and a Task class that extends the RecursiveAction class. This is one of the tasks you can execute in a ForkJoinPool class. When the tasks were processing the array, you printed information about the status of the ForkJoinPool class to the console. You used the following methods to get the status of the ForkJoinPool class:

  • getPoolSize(): This method returns an int value, which is the number of worker threads of the internal pool of a ForkJoinPool class
  • getParallelism(): This method returns the desired level of parallelism established for a pool
  • getActiveThreadCount(): This method returns the number of threads that are ...

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.