Java 8 Streams Java Java API
java.util.stream.BaseStream
boolean isParallel()
Returns whether this stream would execute in parallel during a terminal operation. This method should be called before calling a terminal operation.
package com.logicbig.example.stream;import java.util.stream.Stream;public class IsParallelExample { public static void main(String... args) { Stream<String> stream = Stream.of("one", "two", "three", "four"); stream = stream.parallel(); System.out.println(stream.isParallel()); }}
true
package com.logicbig.example.stream;import java.util.stream.Stream;public class IsParallelExample2 { public static void main(String... args) { Stream<String> stream = Stream.of("one", "two", "three", "four"); System.out.println(stream.isParallel()); }}
false