Answer the question
In order to leave comments, you need to log in
How to execute 1000 times one synchronous function in parallel in NodeJS?
I have one function, it is quite heavy (there may be a loop within a loop, etc.), the execution speed can vary from 10 s - 1 minute, as a result, I need to collect the output of this function together
// fn.js
module.exports = () => {
// high operation
console.log("time result", t);
}
const fn = require("./fn.js");
// нужно выполнить эту функцию 1000 раз параллельно
Answer the question
In order to leave comments, you need to log in
No way - the node works in one thread. Cut the function into pieces, and run in parts (itself, some wq or promises)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question