1.Java IO Model parsing
Perhaps a lot of friends in the study of NiO will feel a little bit of difficulty, many of the concepts are not so clear. Before going into Java NIO programming, let's discuss some of the more basic knowledge today: I/O models. The following article starts with the concept of synchronous and asynchronous, then explains the difference between blocking and non-blocking, then introduces the difference between blocking IO and non-blocking io, then introduces the difference between synchronous IO and asynchronous Io, and then introduces 5 IO models, Finally, two design patterns (reactor and proactor) related to high performance IO design are introduced.
The following is a table of contents outline for this article:
One. What is synchronization. What is asynchronous.
Two. What is blocking. What is non-blocking.
Three. What is blocking IO. What is non-blocking IO.
Four. What is synchronous IO. What is asynchronous IO.
Five. Five kinds of IO models
Six. Two kinds of high-performance io design Patterns
one. What is synchronization. What is asynchronous.
The concept of synchronous and asynchronous has been coming out for a long time, and there are many theories about synchronization and asynchrony on the Internet. The following is my personal understanding:
Synchronization is: If there are multiple tasks or events to occur, these tasks or events must be carried out one at a time, the execution of an event or task will cause the whole process to wait for a while, these events do not have the means to execute concurrently;
Asynchronous: If there are multiple tasks or events, these events can be executed concurrently, and the execution of an event or task will not cause the entire process to be temporarily waiting.
This is synchronous and asynchronous. To give a simple example, if you have a task that includes two subtasks A and B, for synchronization, when a is executed, B waits only until a completes, and B can execute concurrently, and for asynchronous is a and B to execute synchronously, B does not have to wait for a to execute before execution. This will not cause the entire task to wait temporarily because of a's execution.
If you do not understand, you can first look at the following 2 pieces of code:
| 1 2 3 4 5 6 7 8 9 10 11 12 13-14 |
void Fun1 () {} void Fun2 () {} void function () {fun1 (); |