The relationship between java nio and nio

< H2 > when you encounter problems in the past, you can always find absolutely correct answers on the Internet, but now there are many different answers on blogs. For example, about java nio, some people say that it is Synchronize non-blocking, and some people say that it is asynchronous blocking. All I know is that java nio uses the reactor mode, or io multiplexing, and netty is the same way. I hope Big Bird can give me a detailed explanation. Thank you for java nio and linux nio, < / H2 >.
Feb.08,2022

first of all, I'd like to talk about my understanding of Synchronize asynchronous blocking nonblocking:
Synchronize asynchronism refers to whether a thread can handle one thing while it is dealing with another, and then give the result of another thing later
blocking nonblocking refers to whether a thread will be blocked while processing something. (NIO in linux means no block io)
which in java and other programming languages, It should be a programming model,

in linux's IO model, this statement is not true, because no matter what IO model is copied from the kernel to the user mode, it is blocking. Even in the Synchronize non-blocking model,
in the linux model, blocking non-blocking means using the system call to see if the user state is ready for this process. For linux multiplexing, the system call select is also blocked, and there is no way to do other tasks. It looks like it should be Synchronize blocking, but it is much better than linux's Synchronize blocking,
because Synchronize blocking model is for one IO, and multiplexing is for multiple IO,
about linuxIO model: https://www.jianshu.com/p/486.

I have struggled with Synchronize non-blocking and asynchronous non-blocking before, but then I thought about it. Take netty as a whole, it belongs to asynchronous non-blocking. The thread of accept processes the request and passes it to the reactor,
then the thread of accept will not process other requests. This will achieve asynchronous non-blocking. But his internal reactor uses the multiplexing model instead of the real asynchronous non-blocking model,

so having said so much, in fact, I still want to express Synchronize async, blocking and non-blocking. It's just a programming idea. You don't have to struggle, and don't be confused by linux's IO model.

and java's NIO means new IO, not noblock io, because in addition to providing selector, it also provides other io features, such as handling large files

.

it is recommended that you read the second edition of Netty's authoritative guide, which is very clear

.
Menu