Event Loop in Node.js
Last updated on Feb Tue, 2023 5603
As a content writer at HKR trainings, I deliver content on various technologies. I hold my graduation degree in Information technology. I am passionate about helping people understand technology-related content through my easily digestible content. My writings include Data Science, Machine Learning, Artificial Intelligence, Python, Salesforce, Servicenow and etc.
Upcoming Node JS Training Online classes
|Batch starts on 6th Oct 2023||
|Batch starts on 10th Oct 2023||
|Batch starts on 14th Oct 2023||
When the function stack is empty, an event loop is anything that moves items from the queue to the function execution stack.
By using the cluster APIs or the previously described child processes, node.js can have several event loops, but by default only uses one on the main thread.
The Event Loop uses just one thread. It serves as the Node JS Platform Processing Model's main building block. Loop also examines every Client Request put in the Event Queue.
The event loop waits for the Call Stack to be cleared prior to pushing callbacks from the Task Queue to the Call Stack. Once the stack has been emptied, the event loop is started, and checks the Task Queue for any callbacks that might be available.