Why doesn't NIO provide an async-singlethreaded I/O?

Brunoais brunoaiss at gmail.com
Fri Oct 28 10:00:54 UTC 2016


Thank you!

That helped me deciding a possible direction to go to. I'll checkout 
that FileChannel::map method as well as Asynchonous.

I still do not know about why there's no non-blocking I/O in java but 
that's fin, I guess.

I'll see what I can do with this information.


On 28/10/2016 09:46, Alan Bateman wrote:
> On 28/10/2016 08:54, Brunoais wrote:
>
>> Please read the quotes.
>>
>> They are from the thread "Re: Request/discussion: BufferedReader 
>> reading using async API while providing sync API" from the mailing 
>> list core-libs-dev at openjdk.java.net .
>>
>> The main question I have can be summarized to:
>>
>> Why isn't there (or was there) any non-block read-ahead I/O in java's 
>> NIO (more question information in the quotes)?
> If you looking to read ahead then a thread + synchronous I/O should 
> work just fine, you don't need any additions to the Java SE APIs to do 
> that. As always, do your performance tests to see if helps or not. I 
> see Peter has provided some JMH examples, include dropping the file 
> system cache between runs.
>
> One other thing to add to your list to try is memory mapping the file 
> with FileChannel::map and MappedByteBuffer. In particular, see if 
> MappedByteBuffer::load helps.
>
> (Aside from MappedByteBuffer::load, none of the existing APIs map to 
> fadvise or madvise, in particular there is no way to advise that the 
> access is expected to be sequential)
>
> As regards AsynchronousFileChannel (which is the only non-blocking 
> file I/O API in the platform) then it's not for sequential access. You 
> can make it do sequential access of course but it will be a bit of 
> work to do right.
>
> -Alan
>



More information about the nio-dev mailing list