On Oct 30, 2013, at 5:54 PM, Henry Jen <henry....@oracle.com> wrote:

> Looks good to me.
> 

Thanks.


> In the test, 
> 
>> Integer one = Stream.iterate(1, i -> i + 
>> 1).unordered().parallel().distinct().findAny().get();
>> assertEquals(one.intValue(), 1);
> 
> The implementation is probably make sure this will return 1, but is that what 
> we spec to do? I sort of think it can have various values depends on how many 
> working threads and their scheduling.

Stream.iterate produces an ordered sequence of x, f(x), f(f(x)), f(f(f(x))), 
etc. 

Internally the stream is constructed from a spliterator derived from an 
iterator. Although we don't explicitly say it the unary function is never 
called concurrently: applying the function to one element happens-before 
applying the function to subsequent elements, but for any given element, the 
function may be applied in whatever thread the library chooses [*].

Paul.

[*] copied from Stream.forEachOrdered.

Reply via email to