4 ms·
It is executed by your runtime which may or may not behind the scenes be using a single thread for your execution and/or the underlying I/O/eventing going on un
by MuffinFlavored 3y ago
It is executed by your runtime which may or may not behind the scenes be using a single thread for your execution and/or the underlying I/O/eventing going on underneath, no?
- throwitaway1123 3y agoMost JS runtimes are multi-threaded behind the scenes. If you start a node process: node -e "setTimeout(()=>{}, 10_000)" & Then wait a second and run: ps -o thcount $! Or on macOS: ps -M $! You'll see that there are multiple threads running, but like others have said, it's completely opaque to you as a programmer. It's basically just an implementation detail.
- throwitaway1123 3y agoIf you need true parallelism of course you can opt-in to Web Workers (called Worker Threads in Node), or the Node-specific child_process.fork, or cluster module.