Home  >  Article  >  Web Front-end  >  Detailed explanation of synchronization and asynchronousness in JavaScript

Detailed explanation of synchronization and asynchronousness in JavaScript

黄舟
黄舟Original
2017-10-23 10:05:431628browse

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!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn