I played around with this library a bit to see how easy it is to use a worker thread. Whilst I was using it, I stumbled upon weird behavior where the while loop only run once inside the worker thread. Here is the minimal example to reproduce:
import { start, job } from "microjob";
(async () => {
try {
// start worker pool
await start({ maxWorkers: 4 }); // you can also limit the available workers
job(() => {
while (true) {
console.log("inside loop")
}
})
// ...
} catch (err) {
console.error(err);
}
})();
I played around with this library a bit to see how easy it is to use a worker thread. Whilst I was using it, I stumbled upon weird behavior where the while loop only run once inside the worker thread. Here is the minimal example to reproduce: