This article will explain synchronous, asynchronous, blocking, non-blocking, and how IO relates to these four terms, as I was confused when I first learned about them.




🔥1. Synchronous blocking, synchronous non-blocking, asynchronous blocking, and asynchronous non-blocking

1. The synchronous
  • Synchronization is when multiple things do not work at the same time, but queue up
2. The asynchronous
  • Multiple things can work at the same time rather than sequentially
3. The block
  • The thread needs to stop waiting
4. A non-blocking
  • Threads can run work
5. Four-way correlation

Synchronous/asynchronous, it’s all about being able to work at the same time

Blocking/non-blocking, it’s about being able to move

  • Synchronous blocking: Cannot work or move at the same time. Like, there’s only one lane, one car at a time, and sadly, it’s blocked.
  • Synchronous non-blocking, can not start at the same time, but can move. For example, there is only one lane, which can only pass one car at a time, but fortunately it can pass normally.
  • Asynchronous blocking, can start at the same time, but can not move. There are several roads, each road can be a car, but the frustration is that they are all blocked.
  • Asynchronous, non-blocking, can be on or off. There are many roads, each road can be sports car, very cool is all can be normal traffic.


Go back to the program and the corresponding thread is

  • Synchronous blocking, equivalent to a thread waiting.
  • Synchronous non-blocking is equivalent to a thread running normally.
  • Asynchronous blocking, which is equivalent to multiple threads waiting.
  • Asynchronous non-blocking, which is equivalent to multiple threads running normally.





🔥2.IO and the above four

1.I/O, blocking I/O, and non-blocking I/O
  • IO: refers to the process of reading/writing data, andWaiting for theThe process of reading/writing data. Once you get the data, it becomes a data operation, not an IO
    • Blocking IO: user threads are blocked on waiting data or copying data
    • Non-blocking IO: the user thread is not blocked because of THE IO


2. Synchronize I/OS and block I/OS

In IO, synchronous and non-blocking are mutually exclusive, that is, there is no synchronous non-blocking IO, and there is synchronous non-blocking, but that is not called IO, it is called operational data

  • Synchronize I/O data: You can perform the synchronization only after obtaining THE I/O data. The corresponding code reads the file and then operates

  • Non-blocking IO: After an IO request is made, the code can proceed. That is, it must not be synchronized.

Therefore, synchronizing I/O must block I/O, and synchronizing I/O is equal to synchronizing blocking I/O. There is no synchronous non-blocking IO


3. Asynchronous I/OS, asynchronous blocking I/OS, and asynchronous non-blocking I/OS
  • Asynchronous I/O: An asynchronous I/O request can be executed without receiving the I/O data
    • Asynchronously blocking I/O: The thread is blocked during data copy after the I/O request is initiated.
    • Asynchronous non-blocking I/O: After an I/O request is initiated, a notification is received, data is processed, and the process is not blocked.