开发者

Node.js, process and threads question

Does process have at least one thread running?

If so, then the Node.js will by default ha开发者_运维技巧ve 1 main thread and 1 event loop thread running?


No, node.js runs only with one thread. There is no "main thread" and "event loop thread". First run the initialzation code then the event loop is entered. The event loop runs the event and timeout handlers. Exactly as in the browser: first run the initialization code in the <script> tags, then the handlers.

Except the workers, but also here it is the same as in the browser (HTML5 workers). A worker thread or process is started separately to offload long-running calculations and a handler is run when the worker finished its task.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜