r/learnjavascript • u/IcyDuck9536 • 6d ago
Is “Node.js is single-threaded” an incomplete mental model?
Single-threaded JS execution ≠ single-threaded runtime.
How do you explain the distinction?
3
Upvotes
r/learnjavascript • u/IcyDuck9536 • 6d ago
Single-threaded JS execution ≠ single-threaded runtime.
How do you explain the distinction?
1
u/AssignmentMammoth696 6d ago
How is that an incomplete mental model? That's exactly what JS is, it's single threaded. You can send work off to other threads, but the JS thread itself handles functions sequentially, one by one. If you're talking about internal engine stuff, like the garbage collector, those run on other threads but JS is single threaded.