For a long time I thought that event loop implementation (libuv?) used in Chrome and Node.js used threads. But then I was reading this article on lightweight threads in Java that stated the following:
...instead of creating threads for each concurrent task (and blocking tasks), a dedicated thread (called an event loop) looks through all the tasks that are assigned to threads in a non-reactive model, and processes each of them on the same CPU core.
And the the book Computer Systems. A Programmer’s Perspective in the chapter on concurrent applications states that modern operating systems provide three basic approaches for building concurrent programs (3 approaches to implementing logic flows):
Processes. With this approach, each logical control flow is a process that is scheduled and maintained by the kernel. Since processes have separate virtual address spaces, flows that want to communicate with each other must use some kind of explicit interprocess communication (IPC) mechanism.
I/O multiplexing. This is a form of concurrent programming where applications explicitly schedule their own logical flows in the context of a single process. Logical flows are modeled as state machines that the main program explicitly transitions from state to state as a result of data arriving on file descriptors. Since the program is a single process, all flows share the same address space.
Threads. Threads are logical flows that run in the context of a single process and are scheduled by the kernel. You can think of threads as a hybrid of the other two approaches, scheduled by the kernel like process flows and sharing the same virtual address space like I/O multiplexing flows.
So now I'm wondering now if the event loop falls under I/O multiplexing logical flow and doesn't use threads?