Recall & Review
beginner
What is a Worker Thread in Node.js?
A Worker Thread is a way to run JavaScript code in parallel within the same Node.js process. It shares memory with the main thread but runs independently to perform CPU-intensive tasks without blocking the main event loop.
Click to reveal answer
beginner
What is a Child Process in Node.js?
A Child Process is a separate process created by the main Node.js process. It runs independently with its own memory and event loop, allowing you to run external programs or scripts without blocking the main process.
Click to reveal answer
intermediate
How do Worker Threads and Child Processes differ in memory usage?
Worker Threads share memory with the main thread using SharedArrayBuffer, which allows faster communication. Child Processes have separate memory spaces, so communication happens via inter-process messaging, which is slower.
Click to reveal answer
intermediate
When should you use a Worker Thread instead of a Child Process?
Use Worker Threads for CPU-heavy JavaScript tasks that need to run in parallel but share data efficiently. They are lighter and faster for tasks within Node.js. Use Child Processes when you need to run external programs or isolate tasks completely.
Click to reveal answer
advanced
What is a key limitation of Worker Threads compared to Child Processes?
Worker Threads run in the same process, so if a Worker Thread crashes, it can affect the main process. Child Processes are isolated, so a crash in a child does not crash the main process.
Click to reveal answer
Which Node.js feature runs JavaScript code in parallel within the same process?
✗ Incorrect
Worker Threads run JavaScript code in parallel inside the same Node.js process.
Which runs in a separate memory space and process?
✗ Incorrect
Child Processes run in separate processes with their own memory.
Which is better for running external programs from Node.js?
✗ Incorrect
Child Processes are designed to run external programs or scripts.
Which communicates faster due to shared memory?
✗ Incorrect
Worker Threads share memory, enabling faster communication.
What happens if a Worker Thread crashes?
✗ Incorrect
Since Worker Threads share the same process, a crash can affect the main process.
Explain the main differences between Worker Threads and Child Processes in Node.js.
Think about memory, process isolation, and use cases.
You got /5 concepts.
When would you choose a Child Process over a Worker Thread in a Node.js application?
Consider isolation and running non-JS code.
You got /4 concepts.