Request/discussion: BufferedReader reading using async API while providing sync API

Roger Riggs roger.riggs at
Fri Oct 21 17:38:38 UTC 2016

Hi Pavel,

I think Brunoais asking for a double buffering scheme in which the 
implementation of
BufferReader fills (a second buffer) in parallel with the application 
reading from the 1st buffer
and managing the swaps and async reads transparently.
It would not change the API but would change the interactions between 
the buffered reader
and the underlying stream.  It would also increase memory requirements 
and processing
by introducing or using a separate thread and the necessary synchronization.

Though I think the formal interface semantics could be maintained, I 
have doubts
about compatibility and its unintended consequences on existing subclasses,
applications and libraries.

$.02, Roger

On 10/21/16 1:22 PM, Pavel Rappo wrote:
> Off the top of my head, I would say it's not possible to change the design of an
> _extensible_ type that has been out there for 20 or so years. All these I/O
> streams from were designed for simple synchronous use case.
> It's not that their design is flawed in some way, it's that they doesn't seem to
> suit your needs. Have you considered using java.nio.channels.AsynchronousFileChannel
> in your applications?
> -Pavel
>> On 21 Oct 2016, at 17:08, Brunoais <brunoaiss at> wrote:
>> Any feedback on this? I'm really interested in implementing such BufferedReader/BufferedStreamReader to allow speeding up my applications without having to think in an asynchronous way or multi-threading while programming with it.
>> That's why I'm asking this here.
>> On 13/10/2016 14:45, Brunoais wrote:
>>> Hi,
>>> I looked at BufferedReader source code for java 9 long with the source code of the channels/streams used. I noticed that, like in java 7, BufferedReader does not use an Async API to load data from files, instead, the data loading is all done synchronously even when the OS allows requesting a file to be read and getting a warning later when the file is effectively read.
>>> Why Is BufferedReader not async while providing a sync API?

More information about the core-libs-dev mailing list