Stream confusion

Archie Cobbs archie.cobbs at gmail.com
Wed Nov 22 20:52:45 UTC 2023


On Wed, Nov 22, 2023 at 1:46 PM Ron Pressler <ron.pressler at oracle.com>
wrote:

> For example, you can generally submit tasks with non-final fields to
> ExecutorServices backed by thread pools because the writes to the fields on
> the submitting thread “happen before” the submission, and the submission
> “happens before” the execution of the task on the worker thread.


Thanks - I was missing that part. Although the docs don't use the
"happens-before" terminology they do say this:

For well-behaved stream sources, the source can be modified before the
> terminal operation commences and those modifications will be reflected in
> the covered elements.
>

So we would just need to know that our streams are "well behaved"... the
docs say:

All the streams returned from JDK collections, and most other JDK classes,
> are well-behaved in this manner; for streams generated by other libraries,
> see Low-level stream construction
> <https://docs.oracle.com/en/java/javase/21/docs/api/java.base/java/util/stream/package-summary.html#StreamSources>
> for requirements for building well-behaved streams
>

Hmm, that still leaves the door open for "poorly behaved" Streams. It would
be nice if instead "well-behaved" were an explicit requirement.

I don’t think any of this discussion belongs on amber-dev
>

Sorry about that, I'll stop for now.

-Archie

-- 
Archie L. Cobbs
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.org/pipermail/amber-dev/attachments/20231122/e58d61c7/attachment.htm>


More information about the amber-dev mailing list