Loading…
Loading…
Backend · Senior full stack preparation
Reason about the event loop, asynchronous work, parallelism, and worker threads. Read practical answers and use the examples to explain your reasoning.
6 of 6 questions
Node.js is a JavaScript runtime, not a language. JavaScript normally executes on one main event-loop thread per isolate, while runtime facilities and explicit workers can use other threads.
Link to question 23It coordinates non-blocking I/O through the event loop, operating-system facilities, and a runtime thread pool for selected APIs. Awaiting independent I/O allows other work to progress; synchronous computation still blocks its thread.
Link to question 24Use node:worker_threads for CPU-heavy JavaScript. Prefer a bounded pool for recurring jobs and define task messages, timeouts, cancellation, and error handling.
Link to question 25A worker executes JavaScript in its own isolate and event loop. The parent sends inputs and receives outputs through messages. Workers help with CPU work and usually add unnecessary overhead for ordinary asynchronous I/O.
Link to question 26Single-threaded execution describes one isolate. Creating a worker creates another execution environment with its own JavaScript thread within the process.
Link to question 27Use explicit message protocols and task identifiers. Data is generally cloned or transferred; SharedArrayBuffer enables deliberate shared memory with synchronization such as Atomics. Handle worker errors and exits.
Link to question 28