4 ms·
> My favorite is that sequential streams can be efficiently parallelized with a single operation, .parallel(), and sequentialized back, .sequential() That's no
by delusional 3y ago
> My favorite is that sequential streams can be efficiently parallelized with a single operation, .parallel(), and sequentialized back, .sequential()
That's not actually true. .parallel and .sequential set a state flag for the entire stream. A stream that is opened, parallelized, then sequentalized, will actually just execute sequentially [1]
[1]: https://docs.oracle.com/en/java/javase/14/docs/api/java.base/java/util/stream/package-summary.html#Parallelism https://docs.oracle.com/en/java/javase/14/docs/api/java.base...