Event loop (event loop)

Foreword

That event loop browser or Node is used to solve the mechanism blocking javascript single-threaded runtime, also asynchronous principle.


task

In javascript, tasks are divided into macro and micro tasks task.

Task Category


The execution order (browser)

After the completion of the execution stack synchronization tasks, view the execution if the stack is empty, then check if the micro-task queue is empty, the implementation of micro-task queue. And then execute the macro task. Each task must be to see the implementation of a macro-micro task queue, if the micro task queue is not empty, perform micro tasks. Micro task queue is empty, then the implementation of a macro task.


Guess you like

Origin www.cnblogs.com/hengruo/p/12123789.html