The Event Loop

Understand the inner workings of the Event Loop.

Concurrency

While we have praised Node.js for running applications on a single thread, there is more to it. When we ask the OS to read a file for us, we use the file system API. Node.js provides us with several APIs that allow us to make asynchronousprocesses that can run in the background without causing the main program to wait calls. For Node.js, these underlying APIs are written in C++ and threads are hidden from us. If you have ever worked with threads before, you will realize that things can get messy when dealing with multiple threads. Deadlocks and race conditions are the worst, so having Node.js manage that for us is, undoubtedly, a praiseworthy feature.

How does it work?

Let’s take a look at the components that make all of this possible.

Create a free account to view this lesson.

By signing up, you agree to Educative's Terms of Service and Privacy Policy