What is the relationship between the total time spent asynchronously in javaScript and the total time spent adopting Synchronize? How do you judge?

1. What is the relationship between the total time spent asynchronously in javaScript and the total time spent adopting Synchronize? How do you judge?
2, in addition, when asynchronous, the Synchronize task is executed first, and who is executing the asynchronous task, and why is it that when it comes back to execution, the asynchronous task has already been executed? Is it because of browser multithreading?

Apr.01,2021

first point total time relationship
excludes some influencing factors. For a specific set of tasks, the total time spent on asynchronous calls is the longest of these tasks. Synchronize is the sum of time spent on all tasks.

second problem
in the browser engine, single thread means that there is only one thread responsible for interpreting and executing JavaScript code in the JS engine, which is why we often say that js is single-threaded.
however, in addition to the above threads, there are other threads, such as threads that process AJAX requests, threads that handle DOM events, timer threads, and so on, which are also called worker threads.

the workflow is that the js thread receives an asynchronous ajax task and gives the ajax task to the ajax thread. After receiving it, the ajax thread replies that the js thread has received the processing immediately, and after the processing is completed, it informs the js thread that the processing is finished. After receiving the notification, the js thread calls the previously saved queue callback function.
Sorry, it's hard to type on your phone

Menu