Event Queue Mechanism

55 views
Skip to first unread message

essam...@gmail.com

unread,
May 17, 2015, 7:04:50 PM5/17/15
to nod...@googlegroups.com
NodeJS uses a event driven model in which only one thread executes the events. I understand the first event executed will be the user JS code. After that event loop will wait for further messages. My question is which thread enqueue event? Is there are a separate thread that does that? If yes can multiple threads enqueue events also?

Thanks.

// ravi

unread,
May 17, 2015, 9:37:00 PM5/17/15
to nod...@googlegroups.com
On May 17, 2015, at 6:53 PM, essam...@gmail.com wrote:
>
> NodeJS uses a event driven model in which only one thread executes the events. I understand the first event executed will be the user JS code. After that event loop will wait for further messages. My question is which thread enqueue event? Is there are a separate thread that does that? If yes can multiple threads enqueue events also?
>

NodeJS does not expose underlying threads to the application, which has to (therefore) execute in single-threaded mode. I hope that addresses your question (but I am not sure).

—ravi



zladuric

unread,
May 18, 2015, 8:41:58 AM5/18/15
to nod...@googlegroups.com
Yes, there are multiple threads running, but not exposed. There is always only one thread meant for user code, be it on load or as a response on some external action.

But there isn't only one"queue" though. Events get queued and dry for execution in a certain order, but this order isn't fixed.

I hope that helps in addition to what Ravi has said.
Reply all
Reply to author
Forward
0 new messages