This is a fundamental principle of parallel threads that the order of meetings should not match the order of processing. This allows you to simultaneously process elements of subscriptions or subtrees when assembling a correctly ordered result, if necessary. This explicitly allows bulk processing and even makes it mandatory for parallel processing of ordered flows.
This behavior is determined by the specific implementation of the implementation of Spliterators trySplit. The specification says:
If this is a Spliterator ORDERED, the returned Spliterator should cover the strict prefix of the elements
...
API Note:
trySplit ( ) , .
, , . / ?
, . , . . , , , .
. , , , .
, addAll .
, , , , . ORDERED, . , , , , AbstractSpliterator, . , , split .
, .
Stream.generate(()->{
LockSupport.parkNanos(TimeUnit.SECONDS.toNanos(1));
return Thread.currentThread().getName();
}).parallel().forEach(System.out::println);
.