Js synchronization, Asynchronization, blocking, and non-blocking knowledge points
What are you talking about when you are talking about synchronization, Asynchronization, blocking, and non-blocking?
The description of a term should have a target object.
Those who talk about synchronization and Asynchronization never talk about who the target object is. There are many participants in the running process of the program. In the end, this synchronization is used to describe who it is?
In my personal understanding, synchronous and asynchronous descriptions are a behavior method, and blocking and non-blocking descriptions are a state.
In js, we talk about synchronization, that is, synchronous calling. For example:
| The Code is as follows: |
|
Function (){
B ();
C ();
} |
Then A initiates A synchronous call to B and C. The subject here is. When executing A, execute B first. When executing C, they follow A strict sequence. It is actually a sequential execution. This is the specific feature of synchronization.
While asynchronous calling is actually about asynchronous calling. The specific feature is to change the code execution sequence. In js, it is actually about delayed execution.
For example:
| The Code is as follows: |
|
Function (){
SetTimeout (B (), 200 );
C ();
} |
In this case, B is delayed. When A is running, C () is executed first and B () is executed. This is the asynchronous call of a to B .; However, the execution of the setTimeout (B (), 200) Statement and C still follows a strict sequence, but the execution sequence of C and B has changed.
I think it is clearer to describe this phenomenon using synchronous calls and asynchronous calls.