In JavaScript, when one thread executes without relying on other threads to complete processing, we call it asynchronous. On the contrary, one thread must wait until another thread completes processing, which we call synchronization.
For example:
(1) Synchronous means that when you cook instant noodles, you must wait for the water to boil before you add seasonings and instant noodles;
(2) Asynchronous means that when you cook instant noodles, you do not You need to wait for the water to boil. You can put the seasonings and instant noodles when you first start the fire; Single threaded.
But the js execution environment is multi-threaded. If you want to achieve the blocking effect, you can use synchronization or alert()
In the background system, the menu of the background system is allocated according to the different permissions of the login user. Interface, at this time, you need to use the blocking feature of synchronization to generate the menu interface first, and the synchronization js needs to be written before the body.
The above is the detailed content of Detailed explanation of synchronization and asynchronousness in JavaScript. For more information, please follow other related articles on the PHP Chinese website!