The syntax is as follows:
IntStream parallel()
Create an IntStream and you can use the range() method as well to set the range of elements:
IntStream intStream = IntStream.range(20, 35);
Now, use the parallel() method:
intStream.parallel()
The following is an example to implement IntStream parallel() method in Java
import java.util.stream.IntStream; public class Demo { public static void main(String[] args) { IntStream intStream = IntStream.range(20, 35); System.out.println("Parallel IntStream = "); intStream.parallel().forEach(System.out::println); } }
Parallel IntStream = 29 30 28 27 31 25 32 22 34 33 21 26 23 20 24