Interview frequency: …
Short answer
Worker Threads run in the same process, but each has an independent V8 isolate and Heap. They share memory only explicitly through SharedArrayBuffer and are lighter to create, while Child Processes are full operating-system processes with separate memory.
Explanation
The node:worker_threads module runs CPU-intensive JavaScript in separate threads without blocking the Event Loop, and can share memory quickly through SharedArrayBuffer and structured messages over MessagePort. By contrast, node:child_process is used to run external system programs or scripts in other languages (such as Python or bash).
Code example
import { Worker } from "node:worker_threads";
const worker = new Worker("./heavy-calc.js", { workerData: { max: 1e9 } });
worker.on("message", result => console.log("Result:", result));Common mistakes
- Using Worker Threads for ordinary I/O tasks that Node.js already handles well, adding thread-management costs without a benefit.