DEV Community

Discussion on: setTimeout vs setImmediate vs process.nextTick

sachingoel profile image
Sachin Goel

This is not going to affect the result anyway.

Thread Thread
andreasjakof profile image
Andreas Jakof

Not in this case, but if there are three different callbacks set this way, it might be. That's why I'm asking.
Or are they all called at the same time, if you have enough cores? Then they will be started one after another in FIFO order, but they might end in a different order, even if they are doing exactly the same, because of different workloads on different cores.

As long as they are independent it should not matter ... all hail a functional approach. But if you work on the same object with three different callbacks, this might be a question, that could become very important.

Or is all of this dependent on the browser and its JS implementation?

I clearly (luckily?) don't have enough experience with JS, as I am working mostly in the backend.

Thread Thread
logicmason profile image
Mark Author

I think they're FIFO, but I definitely wouldn't rely upon that behavior.

Re: using multiple cores, in that case you're probably running an instance of Node on each and using PM2.