zoukankan      html  css  js  c++  java
  • node异步编程

    串行执行

    (function next(i, len, callback) {
        if(i < len) {
            async(arr[i], function(value) {
                arr[i] = value;
                next(i + 1, len, callback);
            });
        } else {
            callback();
        }
    }(0, arr.length, function() {
        // All array items have processed.
    }));

    并行执行

    (function(i, len, count, callback) {
        for(;i < len; ++i) {
            (function(i) {
                async(arr[i], function(value) {
                    arr[i] = value;
                    if(++count === len) {
                        callback();
                    }
                });
            }(i));
        }
    }(0, arr.length, 0, function() {
        //All array items have processed.
    }));

    https://www.cnblogs.com/TwinklingZ/p/5995689.html

  • 相关阅读:
    leetcode 414
    Leetcode 495
    Leetcode 485题
    Python 24点(2)
    python 24点
    我的第一次作业
    Django
    multiprocessing模块
    遍历文档树
    shutil模块
  • 原文地址:https://www.cnblogs.com/SharkChilli/p/8906315.html
Copyright © 2011-2022 走看看