是真正的NodeJS单线程? [英] Is NodeJS really Single-Threaded?

查看:282
本文介绍了是真正的NodeJS单线程?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Node.js的通过将基于事件的模型为核心,采用事件循环,而不是线程解决每个连接的问题一个线程。
所有昂贵的I / O操作始终异步的初始化操作完成时被执行的回调执行。

Node.js solves "One Thread per Connection Problem" by putting the event-based model at its core, using an event loop instead of threads. All the expensive I/O operations are always executed asynchronously with a callback that gets executed when the initiated operation completes.

如果任何操作occures通过复用机制,例如epoll的处理观察()。

The Observation IF any Operation occures is handled by multiplexing mechanisms like epoll().

我的问题是现在:


  • 为什么犯规阻止的NodeJS同时使用阻塞Systemcalls
    选择/ epoll的/ kqueue的?

  • Why doesnt NodeJS Block while using the blocking Systemcalls select/epoll/kqueue?

或者心不是单一的NodeJS螺纹可言,让第二个线程结果
要注意观察所有的I / O操作与选择/ epoll的/ kqueue的?

Or isnt NodeJS Single Threaded at all, so that a second Thread is
necessary to observe all the I/O-Operations with select/epoll/kqueue?

推荐答案

IS的NodeJS的事件触发的(第二从网站行),不单线程。它在内部处理穿线需要做的选择/ epoll的/ kqueue的处理没有用户明确其来管理,但这并不意味着是在它没有线程使用。

NodeJS is evented (2nd line from the website), not single-threaded. It internally handles threading needed to do select/epoll/kqueue handling without the user explicitly having to manage that, but that doesn't mean there is no thread usage within it.

这篇关于是真正的NodeJS单线程?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆