Asynchronous execution principle

To know the principles of asynchronous execution, you should first understand synchronously. Because the computer program execution is divided into synchronous and asynchronous execution.

The so-called synchronous execution, is the normal order flow executed by the computer:

  1. From left to right top to bottom sequence control statements

  2. The branch control statements if switch 

  3. loop control statement for while do ... while for ... in forEach ()

The so-called asynchronous execution, is a special implementation of the program :

  1.setInterval  setTimeout

  2. Event binding onclick ...

  3.ajax request

  Wait. . .

The so-called asynchronous execution of the program:

 

  1, all asynchronous execution of the program will end after the synchronization program execution, execution again.

 

 

  2, the order asynchronous program, if the same time, the code sequence to see if a different time, a short time before execution.

As shown in FIG :( asynchronous execution)

 

  1, the program beginning with one line of code

  2, synchronous normal program execution.

  3, if found to be asynchronous program execution temporarily stored in the asynchronous pool, awaiting execution.

  4, the program after all the synchronization procedure is completed.

  5, open pool asynchronous execution asynchronous program

    When the set time is reached, it will execute the corresponding asynchronous ascending order, the first-time set of asynchronous program, perform the same if the set time, to see the order asynchronous program to execute.

 

 

(Come on !!! against the war classes ~)

 

Guess you like

Origin www.cnblogs.com/tianlie/p/12643526.html