InputStream/OutputStream concurrency guarantees

Florian Weimer fweimer at redhat.com
Thu Oct 30 17:10:17 UTC 2025


* Viktor Klang:

> Also, since there aren't any consistency effects in place, it is not
> deterministic which changes made by the writer would be seen by the
> reader/copier.

Sure, but if a defensive copy were made, at least the output would be
internally consistent.  This would be similar to what various
byte[]-accepting String methods already do.

But it seems to me that the consensus seems to be that
InputStream/OutputStream do not need to do this, and (for example)
FileInputStream and FileOutputStream could be changed in ways that make
multiple byte array reads and writes observable through race conditions.

Thanks,
Florian



More information about the core-libs-dev mailing list