var async = require(‘async‘);
//串行无关联series
//串行有关联waterfall
//并行:parallel //会把各个函数的执行结果一起放到最后的回调中
async.parallel([
???????function(cb) {
???????setTimeout(function(){
???????console.log(‘111111111‘);
???????cb(null, 1);
???????}, 3000);
???????????????
???????},
???????function(cb) {
???????//console.log(‘one传来:‘+param);
???????setTimeout(function(){
???????console.log(‘222222222‘);
???????cb(null, 2);
???????}, 2000);
???????},
???????function(cb) {
???????//console.log(‘two传来:‘+param);
???????setTimeout(function(){
???????console.log(‘333333333‘);
???????cb(null, 3);
???????}, 1000);
???????}
???],
???????function(err, value) {
???????if(err){
???????console.log(err);
???????}
???????????????// do somethig with the err or values v1/v2/v3
???????????console.log(value);
???????}
);
nodejs并行无关联
原文地址:http://www.cnblogs.com/yu-hailong/p/7439883.html