Does Node.js actually use multiple threads underneath?

后端 未结 1 1259
半阙折子戏
半阙折子戏 2020-12-30 09:13

After all the literature i\'ve read on node.js I still come back to the question, does node.js itself make use of multiple threads under the hood? I think the answer is yes

相关标签:
1条回答
  • 2020-12-30 09:33

    To a Javascript program on node.js, there is only one thread.

    If you're looking for technicalities, node.js is free to use threads to solve asynchronous I/O if the underlying operating system requires it.

    The important thing is to never break the "there is only one thread" abstraction to the Javascript program. If there are more threads, all they can do is queue up work for the main thread in the Javascript program, they can never execute any Javascript code themselves.

    0 讨论(0)
提交回复
热议问题