How to do it...

Follow these steps to implement the example:

  1. First, we'll create some auxiliary classes that we will use later in the example. Review the recipe, Creating streams from different sources, and include in this example the Person and PersonGenerator classes used in it.
  2. Then, create a class named DoubleGenerator. Implement a method named generateDoubleList() to generate a list of double numbers. It receives two parameters with the size of the list we'll generate and the highest value in the list. It will generate a list of random double numbers:
        public class DoubleGenerator {            public static List<Double> generateDoubleList(int size,                                                        int max) {             Random random=new Random();             List<Double> numbers=new ArrayList<>();            for (int i=0; ...

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.