node.js - running a task in parallel in nodejs -


this seems work:

function callloop (n) {   function caller () {     console.log("hello " + n);     settimeout(function () {       caller();     }, 10000);   }    caller(); }  (var = 0; < 5; i++) {   callloop(i); } 

settimeout, in example, instead long-running network call. "correct" way parallelize these network calls?

check out async.parallel:

var async = require( 'async' );  function callloop (n) {   function caller () {     console.log("hello " + n);     settimeout(function () {       caller();     }, 10000);   }    caller(); }  var functions = []; (var = 0; < 5; i++) {   functions.push(callloop.bind(null, i)); }  async.parallel(functions); 

Comments

Popular posts from this blog

java - Run a .jar on Heroku -

java - Jtable duplicate Rows -

validation - How to pass paramaters like unix into windows batch file -