2-- Interview Summary - js-depth understanding of thread Advanced - micro-macro task task

      • Preface:
        Event Loop That time cycle, refers to a browser or Node settlement mechanism does not block the javascript single-threaded runtime, that is, we often use asynchronous principle
      • Js operating mechanism
             1, different operating environment, js operating results are inconsistent
             2, nodeJs based libuv implemented, reference http://docs.libuv.org/en/v1.x/design.html
             . 3, based Chorme
      • Micro-macro task task
            
        • Macro task, macrotask also called tasks. Some callback asynchronous tasks will be time to enter the macro task queue, waiting for the follow-up continue to be invoked, these asynchronous tasks include:
          • setTimeout
          • setInterval
          • setImmwsiate (Node Germany Yes)
          • I / O
          • UI rendering (unique browsers)
        • Micro tasks, microtask, also known as jobs. Other asynchronous tasks callback time into the micro task queue, waiting to be called follow-up, these tasks include asynchronous
          • process.NextTick (Node exclusive)
          • Promise.then()
          • Object.observe
          • MutationObserver
          • (Note: This is only for browsers and NodeJs)
        • ----- Note: new Promise () Constructor which belongs to the synchronization code, rather than micro-task
        • The browser all the macro tasks are executed in an event queue
          every time the event queue tasks put out a micro-micro executing the tasks of an event, and then began to execute event
          • A time to take a macro task
          • Micro perform multiple tasks
          • Micro tasks will be placed at the end of the current cycle time

Guess you like

Origin www.cnblogs.com/janice-jia/p/11789735.html