Aaron
what you are stating doesn't make sense. Javascript is known as a single
threaded...


Henrik,

Why are you stuck on JavaScript engines being "single-threaded"? What Aaron
has been saying makes total sense!

Browsers are MORE than a JavaScript engine. They are multi-threaded
environments. When a JavaScript routine requests async I/O, that request
isn't run in the JavaScript engine. The browser dispatches it to a
different thread in the browser. When that I/O thread completes, then the
browser evokes the callback routine (which is run by the JavaScript
engine).

Similarly when a JavaScript routine requests a callback by registering a
SetTimeout() event, that timeout event is handled by one or more other
browser threads, which are separate from the thread running the JavaScript
engine. After the timeout occurs, the thread which is handling the
event-loop evokes the callback routine in the thread which is running the
JavaScript engine.

As an Amazon Associate we earn from qualifying purchases.

This thread ...

Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.