i have a piece of code like this:
for(let j = 0; j < someNumber; j++) {
const forkedChildOne = fork("./child.js");
const childOne = await new Promise((resolve, reject) => {
forkedChildOne.on('message', (msg){
// someCode
resolve(msg);
});
});
}
for(let i = 0; i < someAnotherNumber; i++) {
const forkedChildTwo = fork("./child_numberTwo.js");
const childTwo = await new Promise((resolve, reject) => {
forkedChildTwo.on('message', (msg){
// someCode
resolve(msg);
});
});
}
but here, first it wait for the first loop to complete then it goes to the second loop. but i need to run them in parallel. how can i do that? thanks.