/** * Java8 中stream流的 forEach 与 foreEachOrdered 的区别 */
public class Main {
public static void main(String[] args) {
List<String> list = new ArrayList<>();
list.add("x");
list.add("y");
list.add("z");
list.parallelStream().forEach(x -> System.out.println(x));
list.parallelStream().forEachOrdered(x -> System.out.println(x));
Stream.of("AAA", "BBB", "CCC").parallel().forEach(s -> System.out.println("Output:" + s));
Stream.of("AAA", "BBB", "CCC").parallel().forEachOrdered(s -> System.out.println("Output:" + s));
}
}