Add application file for BAEL-4496 (#13762)

This commit is contained in:
kpentaris 2023-04-04 14:39:51 +03:00 committed by GitHub
parent e9a2b58924
commit 9df061c513
1 changed files with 20 additions and 0 deletions

View File

@ -0,0 +1,20 @@
package com.baeldung.highcpu;
import java.util.LinkedList;
import java.util.List;
import java.util.function.IntUnaryOperator;
import java.util.stream.IntStream;
public class Application {
static List<Integer> generateList() {
return IntStream.range(0, 10000000).parallel().map(IntUnaryOperator.identity()).collect(LinkedList::new, List::add, List::addAll);
}
public static void main(String[] args) {
List<Integer> list = generateList();
long start = System.nanoTime();
int value = list.get(9500000);
System.out.printf("Found value %d in %d nanos\n", value, (System.nanoTime() - start));
}
}