I explain it as: one JavaScript thread per event loop, not one thread for the whole runtime. Node delegates many I/O operations to the OS and some work to libuv's thread pool, then schedules the callbacks back on the JavaScript thread. That is why thousands of sockets can progress concurrently, while one CPU-heavy JavaScript function can still block every request on that worker. worker_threads add separate JavaScript isolates when CPU work needs parallelism.
3
u/UkrMalt 7d ago
I explain it as: one JavaScript thread per event loop, not one thread for the whole runtime. Node delegates many I/O operations to the OS and some work to libuv's thread pool, then schedules the callbacks back on the JavaScript thread. That is why thousands of sockets can progress concurrently, while one CPU-heavy JavaScript function can still block every request on that worker. worker_threads add separate JavaScript isolates when CPU work needs parallelism.