O'Reilly logo

Java 9 Concurrency Cookbook - Second Edition by Javier Fernández González

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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; ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required