I opened my activity monitory in OSX to to see how Node was getting along and to my surprise it's using 8 threads. How can in be!!?
Asked
Active
Viewed 3,162 times
9
-
Well, is it working OK? – Martin James Feb 07 '14 at 18:40
-
3I think he's confused because Node is single threaded, not because something isn't working correctly. – Abe Miessler Feb 07 '14 at 18:45
-
@MartinJames, yes it's working just fine. I'm just curious. – jwerre Feb 07 '14 at 19:10
-
possible duplicate of [How is Node.js inherently faster when it still relies on Threads internally?](http://stackoverflow.com/questions/3629784/how-is-node-js-inherently-faster-when-it-still-relies-on-threads-internally) – Louis Feb 07 '14 at 19:15
-
4Node is single-threaded from a user application context; it is free to use multiple threads inside the engine. – Joe Feb 07 '14 at 19:18
-
Every IO operation and many other things does use behind the scenes threads (from libraries) to keep you application context unblocked. – moka Mar 19 '14 at 10:44
1 Answers
9
Node.js is single-threaded.
However, it is built on libuv which handles all low-level platform-dependent stuff, including async IO.
Now the issue is that there is no good API for async IO in operating systems nowadays. Different APIs exist, but they all have their issues.
So in order to implement cross-platform async API, libuv emulates it using a thread pool. This is where those threads are coming from.

alex
- 11,935
- 3
- 30
- 42