Can a Stream be sequentially processed for part of the pipeline, and then as parallel?
问题 I have the following code which does not work as I intended (a random line, instead of the first, is skipped): Files.lines(path) .skip(1) .parallel() .forEach( System.out::println ) I have a feeling I misunderstood the behavior of Streams. The question is: Can I first treat a stream as sequential (and use "stateful intermediate operations") and then feed it into a parallel forEach ? 回答1: The entire pipeline is either parallel of sequential. Try using forEachOrdered instead of forEach . In my