Bruce Eckel edd99881d7 Narrowed listing widths, fixed output
Also removed Preferences appendix
2017-05-10 11:45:39 -06:00

24 lines
638 B
Java

// concurrent/Summing4.java
// (c)2017 MindView LLC: see Copyright.txt
// We make no guarantees that this code is fit for any purpose.
// Visit http://OnJava8.com for more book information.
// {ValidateByHand} CI has trouble
import java.util.*;
public class Summing4 {
public static void main(String[] args) {
System.out.println(Summing3.CHECK);
Long[] aL = new Long[Summing3.SZ+1];
Arrays.parallelSetAll(aL, i -> (long)i);
Summing.timeTest("Long Parallel",
Summing3.CHECK, () ->
Arrays.stream(aL)
.parallel()
.reduce(0L,Long::sum));
}
}
/* Output:
50000005000000
Long Parallel: 1014ms
*/