# Blocking/Non-blocking, Sync/Async 의 차이는 왜 물어보는 걸까?

{% hint style="info" %}
`blocking/non-blocking` 과 Sync`/Async`가 다르다는 것은 알겠으나 이것을 구분하는 것은 왜 중요한가?
{% endhint %}

> **Blocking 이면 반드시 Sync 가 아니고, Non-blocking 이면 반드시 async 도 아니다.**

<details>

<summary>Async blocking은 무의미하다는 의견이 있다.</summary>

IO(입출력)를 처리할 때 Sync와 Async의 차이는 그것을 요청한 순서가 지켜지는가 아닌가에 있고 Blocking와 Non-blocking은 그 요청에 대해 받은 쪽에서 처리가 끝나기 전에 리턴해주는가 아닌가에 달려 있습니다.

그래서 3개를 요청했는데 응답에서 그 순서가 지켜진다면 Sync이고 어떤 게 먼저 올지 모른다면 Async입니다. 본문의 설명처럼 하나만 요청한 것으로 Sync와 Async 차이를 설명하는 것은 아주 어렵습니다.

그런 이유에서라도 Async blocking은 무의미합니다. 세번째 보낸 것이 먼저 올 수도 있는데 첫번째 것 보내고 block 할 수는 없죠.&#x20;

다만, 채팅 데몬 같은 것에 종종 쓰이는 select() 함수가 여러 개의 클라이언트 I/O를 기다리면서 block 하고 있어서 IBM에서 설명할 때 굳이 이런 경우는 (어떤 클라이언트의 응답이 먼저 올지 모르는) Async이면서 또 그게 오기 전까지는 계속 대기중인 Blocking이기도 하다고 예를 든 것 뿐입니다.&#x20;

하지만 select() 함수도 시간 지나면 timeout으로 빠져나오게 코딩하기 때문에 꼭 blocking이라고 말하기도 어렵습니다.

</details>

각 조합별 사례가 있고, 각각 쓰임과 한계점이 있기 때문에 구분하는 것 같다!

{% embed url="<https://baek-kim-dev.site/38>" %}

* non-block, sync 사례
* non-block, async 사례
* block, sync 사례
* block, async 사례

{% embed url="<https://velog.io/@minni/Block-vs-Non-Block-Sync-vs-Async>" %}

{% embed url="<https://www.youtube.com/watch?v=ohz7uHnza6A>" %}

## Reference

* [https://haneepark.github.io/2021/07/18/blocking-nonblocking-sync-async](https://haneepark.github.io/2021/07/18/blocking-nonblocking-sync-async/)
* <https://jh-7.tistory.com/25>
* <https://velog.io/@maketheworldwise/SyncAsync-BlockingNon-Blocking-%EB%AC%B4%EC%8A%A8-%EC%B0%A8%EC%9D%B4%EC%9D%BC%EA%B9%8C>


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://programmer-jjy.gitbook.io/second-brain/technical/technical-curiosity/blocking-non-blocking-sync-async.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
