Drop Arrays.parallelStream()?

Brian Goetz brian.goetz at oracle.com
Sat Apr 20 15:28:04 PDT 2013


> For most folks, the expectation and intuition will be sequential, so
> take advantage of that: Let people come to c.stream().parallel() slowly
> and deliberately, after getting their feet wet with c.stream().

I have a slightly different viewpoint about the value of this sequential 
intuition -- I view the pervasive "sequential expectation" as one if the 
biggest challenges of this entire effort; people are *constantly* 
bringing their incorrect sequential bias, which leads them to do stupid 
things like using a one-element array as a way to "trick" the "stupid" 
compiler into letting them capture a mutable local, or using lambdas as 
arguments to map that mutate state that will be used during the 
computation (in a non-thread-safe way), and then, when its pointed out 
that what they're doing, shrug it off and say "yeah, but I'm not doing 
it in parallel."

We've made a lot of design tradeoffs to merge sequential and parallel 
streams.  The result, I believe, is a clean one and will add to the 
library's chances of still being useful in 10+ years, but I don't 
particularly like the idea of encouraging people to think this is a 
sequential library with some parallel bags nailed on the side.




More information about the lambda-libs-spec-experts mailing list