Java 8 Streams Java Java API
Interface:
java.util.stream.BaseStream
Method:
boolean isParallel()
Returns whether this stream would execute in parallel during a terminal operation. This method should be called before calling a terminal operation.
Examples
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()); } }
Outputtrue
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()); } }
Outputfalse
|
|