package alx.p32_parallel_stream.a;

import java.util.Arrays;
import java.util.function.IntUnaryOperator;
import java.util.stream.IntStream;

public class SprawdzanieIleWatkow1 {

	public static void main(String[] args) {
		IntUnaryOperator operacja = x -> {
			System.out.println(Thread.currentThread().getId());
			return 2*x;
		};
		
		int[] tab = new int[100];
		Arrays.fill(tab, 33);
		
		System.out.println("Sekwencyjnie:");
		int suma1 = IntStream.of(tab).map(operacja).sum();
		System.out.println("suma1 = " + suma1);
		System.out.println();

		System.out.println("Parallel:");
		int suma2 = IntStream.of(tab).parallel().map(operacja).sum();
		System.out.println("suma2 = " + suma2);

	}

}
