DB개념 (Blocking/Non-blocking, Synchronous/Asynchronous)

Eungho won·2023년 5월 31일
0

DB

목록 보기
1/1

"Blocking" and "non-blocking", as well as "synchronous" and "asynchronous", are related but distinct concepts. Here's how they fit together:

  1. Blocking: This refers to operations that halt the progress of a program until they complete. For example, a blocking I/O operation would make the program wait until it's finished before the program can proceed.

  2. Non-blocking: This refers to operations that allow a program to continue doing other things without waiting for the operation to complete.

  3. Synchronous: In the context of programming, a synchronous operation is one that waits for a task to complete before moving on to the next task. This means that even though a task might be blocking or non-blocking, if it's synchronous, the program will not proceed until the task is complete.

  4. Asynchronous: An asynchronous operation, on the other hand, allows a program to start a task and then move on to other tasks without waiting for the first task to complete. This operation is particularly useful in managing tasks that are potentially blocking, such as I/O operations or requests to a database.

To illustrate this with a real-world analogy, imagine you're cooking (your program). You put a pot of water to boil (a task). If you stand and watch the pot until it boils before doing anything else, you're acting synchronously and blocking - you're not doing anything else until this task completes. If you start chopping vegetables while waiting for the water to boil, you're acting asynchronously and non-blocking - you started a task (boiling water), but you're not waiting for it to complete before doing other tasks (chopping vegetables).

So, in essence, blocking/non-blocking refers to whether a program has to wait for a task to complete, while synchronous/asynchronous refers to whether a program moves to the next task before the previous one completes. They're different but related concepts - asynchronous operations are often non-blocking, but they don't have to be.

profile
kill to code

0개의 댓글