title: Loops with callbacks in node.js
body: <p>I have the following code in node.js</p>
  
  <pre><code>for (var i = 0; i&lt;allLetters.length; i++)
     for (var k = 0; k&lt;allLetters.length; k++){
          var allFilesName = fs.readdirSync("/opt/ + allLetters[i] + "/" + allLetters[k]);
          for (var t = 0; t&lt; akkFilesName; t++)
                dosomething(allFilesName[t];
           }
  </code></pre>
  
  <p><code>dosomething</code> is a function with callback, and include IO operation.</p>
  
  <p>the problem is that my application doesn't executed the callback until it finish the <code>i, k &amp; t</code> loops. Meaning, I see that all the CPU time is wasted on completed the callback, and just after it complete all the loops, it executed the callback, and returns from the callback. </p>
  
  <p>I want that the loops and the callback will executed parallel, so I would get the result from the callback while I do the loop.  </p>