Consider the classical worker queue: You have a master thread, which takes information from some place, usually a database or some remote system. The data is usually stored in a shared array. There are N workers -> threads which take one element from the array do something with it and then take the second one. If the queue is empty, they simply wait for it to get some information.
In most languages, like C++, Python, Java this would be done with threads. Since NodeJs is asynchronous I was wondering if the following will give a similar effect:
var arr = [21, 22, 23];
arr.forEach(function(entry) {
//do something time/processor consuming
});
Note: This would normally be some object which has to send a request - to the database or to some remote system.
From what I understand 1 closure should be called per array entry and the closures will be called without waiting for the previous closure to finish. In other words, the work on all array entries starts almost at the same time. Is that so ? If not what is node's way to do a worker queue ?
EDIT: I am not looking for exactly a worker queue, rather something similar which fits node's paradigms.