System.IO.File in .NET and .NET Core has a family of Read...Async() methods, all of which return either Task<byte[]> or Task<string> (Task<T> is the .NET's equivalent of Java's Future<T>).
This looks largely equivalent to AsynchronousFileChannel APIs (which either consume a CompletionHandler or return a Future), with one major difference.
AsynchronousFileChanneluses a managed background thread to perform asynchronous I/O (the thread may be provided either by the default thread pool (sun.nio.ch.ThreadPool) or by theExecutorServiceexplicitly specified during channel creation).FileStreamimplementation in .NET, on the other hand, passesFileOptions.Asynchronousflag to the underlying operating system (see also Synchronous and Asynchronous I/O), doesn't spawn any managed background threads and uses what is called an Overlapped I/O.
Questions:
- Is there any (existing or planned) File I/O API in Java which would use Overlapped I/O on Windows and POSIX AIO on Unices? Update: Windows-specific Java runtime features
sun.nio.ch.WindowsAsynchronousFileChannelImplwhich is exactly an abstraction layer on top of Overlapped I/O. - Are there any plans to provide
java.nio.channels.SelectableChannelimplementations for File I/O? If no, what are the technical limitations?
