How to do it...

Follow these steps to implement the example:

  1. First, we'll implement some auxiliary classes we will use in the example. First, implement the Person class, which stores the basic attributes of a person, and the PersonGenerator class, which generates a List of random Person objects. Please, check the recipe Apply an action to all the elements of a stream to see the source code of both classes.
  2. Then, create the Main class with the main() method. First, we'll create a List of random Person objects using the PersonGenerator class:
        public class Main {           public static void main(String[] args) {             List<Person> persons=PersonGenerator.generatePersonList(10);
  1. Then, calculate the maximum and minimum values of the salary field to verify ...

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.