1

I am new to nodejs. After reading few articles I understood that nodejs is single threaded. I am totally surprised that how nodejs handles multiple client requests. For example, if one user hit node server, other user request has to wait until it responds to first client request. Please help me to understand how node works in single threaded environment.

1 Answers1

1

When people say Node is single threaded what they mean is that there is only one thread of JavaScript code being executed. But that does not mean that there aren't other thread executing. For example, most I/O in Node is asynchronous by default and that spins up other threads.

I've posted a diagram in this question Thread in an event-driven vs non-event driven web server that shows how these threads work and for the most part my assumption #4 in that question seems to hold true.

Community
  • 1
  • 1
Hector Correa
  • 26,290
  • 8
  • 57
  • 73