This is the case. The delay time of setTimeout is relative to the time when it is called. The first blocking time of 1000ms in while is included in the 5000 of setTimeout. After the second 5000ms is executed similarly, it It will be judged whether the delay time of setTimeout at this time has passed 2000ms compared to before. If it has passed, it will be executed immediately. In fact, the time using time is the value of MAX (setTimeout, while ())
Although settimeout will be pushed onto the stack, the delay time will not change. As long as there is no blocking and the time is reached, the first blocking 1000ms will be executed, and then the 1000ms of the blocking delayed by 5000ms will be included. The second blocking will be executed after 5000ms. Execute immediately and delay 2000ms
This is the case. The delay time of setTimeout is relative to the time when it is called. The first blocking time of 1000ms in while is included in the 5000 of setTimeout. After the second 5000ms is executed similarly, it It will be judged whether the delay time of setTimeout at this time has passed 2000ms compared to before. If it has passed, it will be executed immediately. In fact, the time using time is the value of MAX (setTimeout, while ())
Although settimeout will be pushed onto the stack, the delay time will not change. As long as there is no blocking and the time is reached, the first blocking 1000ms will be executed, and then the 1000ms of the blocking delayed by 5000ms will be included. The second blocking will be executed after 5000ms. Execute immediately and delay 2000ms