javascript - How to run all functions in parallel -


i posting below piece of code "not async functions"

var flag = false; function a() {     var = 0;     (var = 0; < 10000000; i++) {         a++;     }     console.log("first fun finished!");     flag = true; };  function b() {     var = 0;     (var = 0; < 10000000; i++) {         a++;     }     console.log("second fun finished!"); };  function c() {     var = 0;     (var = 0; < 10000000; i++) {         a++;     }     console.log(a) }; a(); b(); console.log("this should good"); if (flag) { //should wait value before c() called     c();     console.log("third fun finished!") } 

if run above example, should , c() function, have wait untill a() , b() functions finish work. expecting functions should run parrallel (multithread (async) functions). can 1 me how can achieve using nodejs

use promise.all or promise.join.

var promise = require('bluebird'); return promise.join(promise.resolve().then(a),                     promise.resolve().then(b),                     promise.resolve().then(c),                     function(){console.log('complete')}); 

Comments

Popular posts from this blog

toolbar - How to add link to user registration inside toobar in admin joomla 3 custom component -

linux - disk space limitation when creating war file -