Demo for Parallel Core Collection API
paul.sandoz at oracle.com
Tue Feb 4 09:34:28 UTC 2014
On Feb 4, 2014, at 2:58 AM, Tristan Yan <tristan.yan at oracle.com> wrote:
> Hi Paul
> I know this may be a little bit late.
Yes, likely too late... (see below).
> But I am still asking you review this.
> This is a whole demo code include the stream demo code you reviewed before also included parallel part. There is one other parallel demo that Paul has already pushed.
> Could you please review it again?
- There is no parallel execution; one can write as follows for better splitting:
return IntStream.range(0, n).mapToObj(i -> matrix).
- While the approach is interesting (elegant in terms of the reduction) one is not likely to observe any speed up (did you measure?) since the long value will overflow on the 93rd number . You would need to use BigInteger and a larger number of iterations.
- In rotate/shift/zoom/invert the inner range (over height) should not be parallel, it's just gonna fight for resources with the outer range (over width).
- It's not entirely clear to me if BufferedImage is thread safe to concurrently set the pixels
- hit() method is no longer used.
- better to use ThreadLocalRandom or SplittableRandom, as both of those produce higher quality sequences of random numbers.
- i don't think this example has much value as there are better ways to determine primes. As i have said before, if you want to show a simple example it is better to show the parallel generation of probable primes using BigInteger.
I am sorry to have to say this, i know if you have worked on this for a while, but i think this is now too late to go through another round of reviews.
 Think rabbits!
You can think
More information about the core-libs-dev