java io model highlights

java io model highlights

bio (blocking)

Synchronous IO accepts requests and processes requests with the same thread

aio

The application thread will register a socket request with the system, as well as a callback method, and continue to execute. The data monitoring of the socket receiving area is handed over to the system. When the data reaches the receiving area, the system reads the data in the receiving area into the buffer of the application program, and then calls the registered method to read the data.

nio (asynchronous non-blocking)

Similar to aio, the difference is that when the aio callback completes the event, the data has been copied to the application (jvm), and noi also needs to read from the receiving area of ​​the system through the API. The choice of receive buffer is very important.
There are three main types of buffers: jvm, jvm, and file mapping (mappedbytebuffer). The main choice of noi is the buffer outside the jvm.
The factors that affect the performance of a good buffer are: simultaneous reading and writing, and dynamic expansion of the size.
It determines the stability and high efficiency of asynchronous communication. An implementation framework of nio is netty, he designed a set of interface bytesbuf, compositebytebuf implementation class, you can implement your own bytesbuf implementation class according to your needs.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325277628&siteId=291194637