Swiftorial Logo
Home
Swift Lessons
Tutorials
Learn More
Career
Resources

Node.js FAQ: Top Questions

25. What are worker threads in Node.js?

Worker threads , introduced in Node.js 10 (stable in 12), allow running JavaScript in parallel threads, bypassing the single-threaded event loop for CPU-intensive tasks.

  • Module: worker_threads , provides Worker , parentPort .
  • Communication: Message passing via postMessage and on("message") .
  • Limitations: Not for I/O-bound tasks; overhead for thread creation.
  • Use Case: CPU-heavy computations (e.g., crypto, image processing).