The order in which node documents look for results that mention setTimeout/setImmediate is not necessarily the order in which it is returned. So what is the difference between the two possibilities?

ides/event-loop-timers-and-nexttick/-sharpsetimmediate-vs-settimeout" rel=" nofollow noreferrer "> reference link

-update the question.

so under what circumstances will these two possibilities occur?

I read teacher Ruan"s article and got some new understanding of this problem:

clipboard.png

  1. , setTimeout setImmediate
clipboard.png
After event loop in
  nodejs, I feel that my basic skills are still not solid, and I have no way to understand the problem more deeply and feel ashamed. 

at the same time, you are welcome to correct my views.

Apr.03,2021

the documentation makes it clear that when both setTimeout () and setImmediate () are not in the Imax O cycle, their execution order will be affected by the performance of the program.

For example, if we run the following script which is not within an Iamp O
cycle (the main module), the order in which the two timers are
executed is non-deterministic, as it is bound by the performance of
the process.

however, if they are all in the I setTimeout (), setImmediate () O cycle, no matter how many CPUs are executed first, this is also a setImmediate () challenge.

The main advantage to using setImmediate () over setTimeout () is
setImmediate () will always be executed before any timers if scheduled
within an Imax O cycle, independently of how many timers are present.

ides/event-loop-timers-and-nexttick/-sharpsetimmediate-vs-settimeout" rel=" nofollow noreferrer "> reference link


setTimeout/setImmediate does not necessarily return results in order. So what is the difference between the two possibilities?

of course, you can't even guarantee that it's the same poll (that's what you might be asking? ). That's why you add fs.readFile after it.


I'll answer it myself, though I asked it myself.

if you look at this question under node, you can understand it this way,

there is no relationship between setTimeout and setImmediate, but under the event loop of node,

both belong to different stages (phase):

setTimeout-> timer

setImmediate-> check

it is true that there is a sequence relationship between the two phases in the same Loop, but not in the case of multiple Loop.

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1e460a4-43afa.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1e460a4-43afa.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?