OnJava8-Examples/arrays/ParallelSetAll.java

25 lines
703 B
Java
Raw Normal View History

2016-01-25 18:05:55 -08:00
// arrays/ParallelSetAll.java
// (c)2016 MindView LLC: see Copyright.txt
// We make no guarantees that this code is fit for any purpose.
2016-09-23 13:23:35 -06:00
// Visit http://OnJava8.com for more book information.
2016-01-25 18:05:55 -08:00
import java.util.*;
import onjava.*;
public class ParallelSetAll {
2016-07-07 15:57:38 -06:00
static final int SIZE = 10_000_000;
2016-01-25 18:05:55 -08:00
static void intArray() {
int[] ia = new int[SIZE];
Arrays.setAll(ia, new Rand.int_()::get);
Arrays.parallelSetAll(ia, new Rand.int_()::get);
}
static void longArray() {
long[] la = new long[SIZE];
Arrays.setAll(la, new Rand.long_()::get);
Arrays.parallelSetAll(la, new Rand.long_()::get);
}
public static void main(String[] args) {
intArray();
longArray();
}
}