title: Understanding Node.JS async.parallel
body: <p>I need to request data from two web servers. The tasks are independent; therefore, I am using <a href="https://github.com/caolan/async" rel="noreferrer">aync.parallel</a>. Now I am only writing 'abc', 'xyz', and 'Done' to the body of my web page.</p>
  
  <p>Since tasks are performed at the same time, can I run into a strange output? E.g.,</p>
  
  <pre><code>xab
  cyz
  </code></pre>
  
  <p><strong>The code.</strong></p>
  
  <pre><code>var async = require('async');
  
  function onRequest(req, res) {
      res.writeHead(200, {
          "Content-Type" : "text/plain"
      });
  
      async.parallel([ function(callback) {
          res.write('a');
          res.write('b');
          res.write('c\n');
          callback();
      }, function(callback) {
          res.write('x');
          res.write('y');
          res.write('z\n');
          callback();
      } ], function done(err, results) {
          if (err) {
              throw err;
          }
          res.end("\nDone!");
      });
  
  }
  
  var server = require('http').createServer(onRequest);
  server.listen(9000);
  </code></pre>