Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我在 OSX 中打开了我的活动监视器,以查看 Node 的运行情况,令我惊讶的是它使用了 8 个线程。怎么可能!!
Node.js 是单线程的。
然而,它是建立在 libuv 之上的,它处理所有低级平台相关的东西,包括异步 IO。
现在的问题是现在操作系统中没有好的异步 IO API。存在不同的 API,但它们都有自己的问题。
所以为了实现跨平台的异步 API,libuv 使用线程池来模拟它。这就是这些线程的来源。