I'm new to javascript and node.js,
Here I have two loops, I want to let them run in parallel,
function loop1(){
for (var i = 10000; i < 20000; i++) {
console.log(i);
}
}
function loop2(){
for (var i = 0; i < 10000; i++) {
console.log(i);
}
}
loop1();
loop2();
Which means the output I expected is like
10000
0
10001
1
...
19999
9999
But this outputs
10000
10001
...
19999
0
1
...
9999
I have tried using promises like
Promise.all([loop1(), loop2()])
But nothing happened.
Is there any idea about this? My final target is to split files in a folder's into half and process them in parallel. So Multi-Threading or Multi-Processing might be acceptable. Thanks for your help.