As far as I'm aware, in parallel streams, methods such findFirst
, skip
, limit
and etc. keep their behaviour as long as stream is ordered (which is by default) whether is't parallel or not. So I was wondering why forEach
method is different. I gave it some thought, but I just could not understand the neccessity of defining forEachOrdered
method, when it could have been more easier and less surprising to make forEach
ordered by default, then call unordered
on stream instance and that's it, no need to define new method.
Unfortunately my practical experience with Java 8 is quite limited at this point, so I would really appreciate if someone could explain me reasons for this architectural decision, maybe with some simple examples/use-cases to show me what could go wrong otherwise.
Just to make it clear, I'm not asking about this: forEach vs forEachOrdered in Java 8 Stream. I'm perfectly aware how those methods work and differences between them. What I'm asking about is practical reasons for architectural decision made by Oracle.