×
Jinxia Li

Concurrency & the Event Loop

No Comments

What you should understand before you can understand things like:

JavaScript has a concurrency model based on an event loop, which is responsible for executing the code, collecting and processing events, and executing queued sub-tasks. This model is quite different from models in other languages like C and Java.

A very interesting property of the event loop model is that JavaScript, unlike a lot of other languages, never blocks. Handling I/O is typically performed via events and callbacks, so when the application is waiting for an IndexedDB query to return or an XHR request to return, it can still process other things like user input.

Exception Control Flow Forms:

1) Operating system level – Context switch

2) Higher-level software form – Linux Signal

Process & I/O:

To really understand I/O, you need to understand process;

To really understand process, you need to understand I/O;

Concurrent Programming (with process/thread/I/O multiplexing):

One thread = one stack = one things at time

Main thread (stack) & Web API threads (Stacks)?

Reference –

https://en.wikipedia.org/wiki/Event-driven_programming

https://developer.mozilla.org/en-US/docs/Web/JavaScript/EventLoop

Leave a Comment

Your email address will not be published. Required fields are marked *

By commenting you accept the Privacy Policy