Programming/FULL STACK

[Node.js] 동기와 비동기 , 그리고 블로킹과 논 블로킹

RosyPark 2021. 1. 20. 00:09

 

1. 동기(Synchronous) vs 비동기(Asynchronous) 

 

Q. 동기와 비동기적으로 일을 처리?

 

빨래, 설거지, 청소를 해야한다. 일처리에 대해서 비유를 해보자 

 

동기 -> 빨래를 한 뒤(1시간), 설거지 한 뒤(1시간), 청소를 해서 일을 끝내는 것(1시간) -> 약 3시간

 

 

 

비동기 -> 빨래 업체한테 맡기고 (1분), 설거지 업체에 맡기고(1분), 청소하는 업체 맡기고(1분) -> 약 3분

-  순서가 중요하지 않다면 비동기적으로 업무를 실행하는 것이 맞다.   

 

 

동기와 비동기의 차이점은? 함수가 바로 return 되는지 여부 

 

 

https://adrianmejia.com/asynchronous-vs-synchronous-handling-concurrency-in-javascript/

 

 

 

2.  블로킹(Blocking) vs 논 블로킹 (Non Blocking) 

블로킹과 논 블로킹? 백그라운드 작업 완료 여부에 나뉘어짐

노드에서는 동기-블로킹방식과 비동기-논블로킹 방식이 대부분

 

 

https://adrianmejia.com/asynchronous-vs-synchronous-handling-concurrency-in-javascript/

 

 

<출처>

1. 생활코딩 -  https://www.youtube.com/watch?v=jjypeFGJC3c

2. https://adrianmejia.com/asynchronous-vs-synchronous-handling-concurrency-in-javascript/

 

What every programmer should know about Synchronous vs. Asynchronous Code

There are multiple ways of handling concurrency on programming languages. Some languages use various threads, while others use the asynchronous model. We are going to explore the latter in detail and provide examples to distinguish between synchronous vs.

adrianmejia.com

3.