2

Iam new to nodeJS. I want to know how nodejs is handling the non-blocking IO eventhough it is single threaded. Gone through so many articles, still those didn't clarify my doubt.

Please some explain this with the help of example/diagram that would be great. Thanks in advance.

Sarun UK
  • 6,210
  • 7
  • 23
  • 48
  • 2
    Most recommended resource https://www.youtube.com/watch?v=8aGhZQkoFbQ – abdulbarik Aug 30 '16 at 09:14
  • 1
    Here is the things which can help you a lot http://stackoverflow.com/questions/14795145/how-the-single-threaded-non-blocking-io-model-works-in-node-js/14797359#14797359 – abdulbarik Aug 30 '16 at 09:29
  • Thanks abdulbarik, that video really helped me. – Sarun UK Aug 31 '16 at 06:20
  • Possible duplicate of [How the single threaded non blocking IO model works in Node.js](https://stackoverflow.com/questions/14795145/how-the-single-threaded-non-blocking-io-model-works-in-node-js) – Yilmaz Jun 22 '19 at 06:19

3 Answers3

1

Node JS Single Threaded Event Loop Model.

Please check here for more details with diagrams.

Some more links which help you like as follows :

  1. What the heck is the event loop anyway?
  2. Why is Node.js single threaded?

Hope this will help you !

Community
  • 1
  • 1
Santosh Shinde
  • 6,045
  • 7
  • 44
  • 68
1

Node JS works on single thread that doesn't mean if it is exactly having 1 thread. Actually it has a pool of worker threads which it uses to perform I/O operations.

While i/o operations are being performed by other threads the main thread is idle to receive any input operation. See it here

Community
  • 1
  • 1
vkstack
  • 1,582
  • 11
  • 24
0

Here is a useful link to the question

Hope this will give a further better understanding for single threaded node js execution.

Community
  • 1
  • 1
kv89
  • 13
  • 6