Recent Node.js versions contain the new module worker_threads
which is said to bring multi-threading to Node.js. However, it seems using processes underhood: https://nodejs.org/api/worker_threads.html#worker_threads_new_worker_filename_options
A worker is created from file, and it does actually have stdout
, stderr
. Is Node.js worker_threads
module bringing in multi-threading or just multiple processes with IPC?
Side thing, JavaScript has built-in worker threads (web workers) but no require
or import
, possible to require/import other modules inside the built-in worker threads?
The answer is those worker threads seem real threads. The proof is that printing process.pid
out from the main process file and the worker file yields the same value.
Having stdout, stderr confused me at first.