I am posting a below piece of code which is "Not async functions"
var flag = false;
function a() {
var a = 0;
for (var i = 0; i < 10000000; i++) {
a++;
}
console.log("first fun finished!");
flag = true;
};
function b() {
var a = 0;
for (var i = 0; i < 10000000; i++) {
a++;
}
console.log("second fun finished!");
};
function c() {
var a = 0;
for (var i = 0; i < 10000000; i++) {
a++;
}
console.log(a)
};
a();
b();
console.log("This should be good");
if (flag) { //Should wait for this value before c() is called
c();
console.log("third fun finished!")
}
If we will run above example, This should be good and c() function, will have to wait untill a() and b() functions will finish to work. I am expecting all the functions should run parrallel (multithread (async) functions). Can any one help me how can I achieve it using nodejs