BIO, NIO, AIO What is the difference

BIO, NIO, AIO What is the difference

BIO:Block IO

 同步阻塞式 IO,就是我们平常使用的传统 IO,它的特点是模式简单使用方便,并发处理能力低。

NIO:No Block IO

Synchronous non-blocking IO, is the upgrading of traditional IO, the client and the server through Channel (channel) communication, to achieve multiplexing.

AIO:Asynchronous IO

NIO is an upgrade, also known as NIO2, implements event-based and callback mechanism for asynchronous non-blocking IO operation, asynchronous IO's.

  • BIO is a connecting thread .
  • NIO is a request thread .
  • AIO is a valid request a thread .

BIO : synchronous and blocking, server mode to achieve a thread connection , that the client has a connection request on the server side need to start a thread for processing, if the connection does not do anything to cause unnecessary overhead of thread, of course, can improved thread pooling mechanism.

The NIO : synchronous non-blocking, the server mode to achieve a request thread , i.e., the connection request sent by the client are registered to the multiplexer , the multiplexer polling the connected I / O request when a start thread for processing.

The AIO : asynchronous nonblocking server implementation mode is a valid request for a thread , the client I / O requests are completed by the OS to the notification server and then to start the application process threads.

Applicable scene analysis

The number of connected mode applies to relatively small BIO and fixed architecture, server resources in this way is relatively high, limited concurrent applications, the JDK1.4 previously only option, but the program intuitive and easy to understand.

NIO connection number suitable for multi-mode and connected to short (light operation) architecture, such as chat server, limited concurrent applications, more complex programming, starts the JDK1.4 support.

AIO way to use more than the number of connections and the connection is relatively long (heavy operation) architecture, such as the album server, call the OS to fully participate in concurrent operation, programming is more complex, JDK7 began to support.

Published 12 original articles · won praise 0 · Views 56

Guess you like

Origin blog.csdn.net/DavinDeng/article/details/104917998