zoukankan      html  css  js  c++  java
  • nodejs并行无关联

    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);
    }
    );

  • 相关阅读:
    InitializingBean
    线程池
    maven
    mysql主从库
    zookeeper
    分布式服务框架 Zookeeper -- 管理分布式环境中的数据
    远程调试
    enum
    注解
    Shell错误[: missing `]'
  • 原文地址:https://www.cnblogs.com/yu-hailong/p/7439883.html
Copyright © 2011-2022 走看看