Principle asynchronous execution and implementation instructions

The computer program execution is divided into synchronous execution and asynchronous execution

Synchronous execution : 3 large order flow is a normal computer programs executing
sequence control statements: top to bottom, from left to right
branch control statements: if, switch
loop control statements: for, while, do ... while , for ... in, forEach ()

Asynchronous execution : implementation is a special program
setInterval setTimeout
binding the onclick event ...
ajax request

Asynchronous execution procedure :
First, all asynchronous execution program will end after the synchronization program execution performed again
two, asynchronous execution sequence of the program, if the same time, the order codes see
if a different time, short time, the first carried out

setInterval(function(){
            console.log('我是异步执行的程序1111');
        } , 2000);
        setInterval(function(){
            console.log('我是异步执行的程序2222');
        } , 1000);
        console.log('我是同步执行的程序')

Asynchronous process program executed :
1, a line of code from the program execution starts
2, the synchronization executing program normally
3, if found to be asynchronous to program, temporarily performed
in the asynchronous storage pool, awaiting execution
4, the synchronization procedure is completed all of the program after
5, pool enables 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.

It must be borne in mind that the implementation of asynchronous program, it must be after all the synchronization program finishes its execution will begin.

Released seven original articles · won praise 0 · Views 75

Guess you like

Origin blog.csdn.net/weixin_43310703/article/details/105330813