I'm trying to use async
node module for my project I need it in huge way. when I tried follow code than it's not working. Please any one help me to figure out issue.
async.parallel({
test : function(callback) {
for(var i=0; i<1000000000; i++){
if(i == 999999999){
console.log("test");
callback(null, "test");
}
}
},
test1 : function(callback) {
console.log("test1")
callback(null, "test1");
}
}, function(err, results) {
// optional callback
console.log('results', results)
});
How these code would be execute ? I tried it's print { test: 'test', test1: 'test1' }
but as per logically if parallel process executed than need output like { test1: 'test1', test: 'test' }
.
If I use timeout
insted of for loop
than it's working fine.
this from async doc
So, youre For loop is do task in sync way