In node.js
app.use((req, res, next) => {
setImmediate( () = {
heavyTask();
});
function heavyTask(){
for (let i = 0; i < 100000; i++) {
for (let i = 0; i < 100000; i++) {
for (let i = 0; i < 3; i++) {
}
}
}
}
});
I set up 2 users (userA, userB) in local dev. Whenever I use userA to trigger this function, other users like userB has to wait in line although these users are performing simpler task that takes a few ms. I'm definitely misunderstood something about setImmediate. I thought it's supposed to prevent blocking of event loop so other users don't have to wait in line when other users do expensive calculation.
The answer I'm looking for is by example using this code above.