You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I recently found that async doesn't run things in parallel at all. It isn't async to blame; it is NodeJS. Async takes advantage NodeJS's non-blocking feature. So, when one task idles or pauses, another jumps in. Async manages that; it manages what jumps in. Nothing ever really happens at the same time. You would need child processes or threads for that.
I stumbled upon this with this Stack Overflow answer. I was testing my app and only using console.log and standard JavaScript functions that happen in an instant in async.each(). The console showed that the each was actually maintaining the order of the array. I had always thought that things were happening at the same time. Some were directed instantly to console.log while others had to go through if statements before console.log. I expected some to finish first.
Since async may be the first library that many people new to NodeJS learn (including me), it should be made clear how async's parallel and series works.
The text was updated successfully, but these errors were encountered:
I recently found that async doesn't run things in parallel at all. It isn't async to blame; it is NodeJS. Async takes advantage NodeJS's non-blocking feature. So, when one task idles or pauses, another jumps in. Async manages that; it manages what jumps in. Nothing ever really happens at the same time. You would need child processes or threads for that.
I stumbled upon this with this Stack Overflow answer. I was testing my app and only using
console.log
and standard JavaScript functions that happen in an instant inasync.each()
. The console showed that theeach
was actually maintaining the order of the array. I had always thought that things were happening at the same time. Some were directed instantly toconsole.log
while others had to go through if statements beforeconsole.log
. I expected some to finish first.Since async may be the first library that many people new to NodeJS learn (including me), it should be made clear how async's parallel and series works.
The text was updated successfully, but these errors were encountered: