Reputation: 37
NodeJs is a single-thread. When I want to work some high cpu tasks, I can use child_process or cluster to work. Now, my question is why NodeJs provide child_process rather than child_thread? Just it is a single-thread?
Upvotes: 1
Views: 43
Reputation: 6015
Nodejs indeed has a single threaded event loop, each child process spawned is a separate single threaded process.
Perhaps that's a reason why this is so.
p.s. internally the engine is multi threaded - read on: How to create threads in nodejs, https://softwareengineeringdaily.com/2015/08/02/how-does-node-js-work-asynchronously-without-multithreading/
Upvotes: 1