Bird
0
0

What method does a worker thread use to send data back to the main thread in Node.js?

easy📝 Conceptual Q2 of 15
Node.js - Worker Threads
What method does a worker thread use to send data back to the main thread in Node.js?
Asend()
Bemit()
CpostMessage()
Dwrite()
Step-by-Step Solution
Solution:
  1. Step 1: Recall worker communication methods

    Worker threads use a method to send messages to the parent thread.
  2. Step 2: Identify the correct method name

    The method to send messages is postMessage(), similar to web workers.
  3. Final Answer:

    Workers use postMessage() to send data -> Option C
  4. Quick Check:

    Worker sends data with postMessage() [OK]
Quick Trick: Use postMessage() to send data from worker [OK]
Common Mistakes:
  • Using send() which is not a worker method
  • Confusing emit() with EventEmitter
  • Using write() which is for streams

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Node.js Quizzes