In java 8 documentation (doc order stream), one can see this :
if [a stream] is not ordered, repeated execution might produce different results.
the documentation of Stream#forEach is already said as below:
The behavior of this operation is explicitly nondeterministic. For parallel stream pipelines, this operation does not guarantee to respect the encounter order of the stream, as doing so would sacrifice the benefit of parallelism.
so the following test should be pass:
List ordered = Arrays.asList(1, 2, 3, 4);
List unordered = new CopyOnWriteArrayList<>();
ordered.stream().parallel().forEach(unordered::add);
assertThat(unordered, not(equalTo(ordered)));
and the operation Stream#findAny also is nondeterministic.