Async.Parallel is the control method of the IO parallel in the process control, if there is no IO operation inside the async.parallel, the function execution in the inside is serial.
Here we discuss the problem of parameter reception, on the code:
var async = require (' async '), function Process1 (CB) {var tx1 = {address: ' Dadada '};var total1 = 1;return CB (NULL,TX1,TOTAL1) ;} function Process2 (CB) {var tx2 = {address: "qweweee"};var Total2 = 2;return CB (NULL,TX2,TOTAL2);} Async.Parallel ([function (done) {Process1] (done),},function (done) {process2 (done);}],function (err,tx,total) { Console.log (Tx[0][0]) Console.log (tx[0][1]); Console.log (tx[1][0)); Console.log (tx[1][1]);//console.log (Total[0]) ;//console.log (total[1);});
Can see PROCESS1 and process2 have three parameters, we receive the time is not to use three parameters to receive it? In fact, in addition to the first err, only need a accept parameter can be, if there is superfluous, then he is in the form of an array to display, the above code to run the result is:
{address: ' Dadada '}1{address: ' Qweweee '}2
Nodejs Async.Parallel parameter Receive