Java Advanced IO---In-depth understanding of BIO, NIO, AIO

Java advanced IO-deep understanding of BIO, NIO, AIO

Reprinted: https://www.imooc.com/article/265871

Development direction
BIO–>NIO–>AIO

1. BIO is the traditional java.io package, which is implemented based on the flow model, and the way of interaction isSynchronization, blockingThe way, that is to say, when reading the input stream or output stream, the thread will always be blocked there until the read and write action is completed, and the calls between them are in a reliable linear order. Its advantage is that the code is relatively simple and intuitive; its disadvantage is that the efficiency and scalability of IO is very low, which easily becomes an application performance bottleneck.

2. NIO is the java.nio package introduced by Java 1.4. It provides new abstractions such as Channel, Selector, Buffer, etc., which can build multiplexed,Synchronous non-blocking The IO program also provides a data operation method that is closer to the low-level high-performance of the operating system.

3. AIO is a package introduced after Java 1.7. It is an upgraded version of NIO and providesAsynchronous non-blockingIO operation method, so people call it AIO (Asynchronous IO). Asynchronous IO is implemented based on the event and callback mechanism, that is, the application will return directly after the operation and will not be blocked. When the background processing is completed, the operating system will notify The corresponding thread performs subsequent operations.

See the reprint link for details

Guess you like

Origin blog.csdn.net/qq_43288259/article/details/113525445