parallel()
Java中LongStream类的方法返回并行的等效流。
语法如下:
LongStream parallel()
要在Java中使用LongStream类,请导入以下包
import java.util.stream.LongStream;
以下是parallel()
在Java中实现LongStream方法的示例:
import java.util.stream.LongStream; public class Demo { public static void main(String[] args) { LongStream longStream = LongStream.range(10L, 20L); System.out.println("Parallel LongStream = "); longStream.parallel().forEach(System.out::println); } }
Parallel LongStream = 16 15 10 17 11 13 12 19 18 14