Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

While loop only run once inside worker thread #72

Open
issadarkthing opened this issue Jun 28, 2021 · 0 comments
Open

While loop only run once inside worker thread #72

issadarkthing opened this issue Jun 28, 2021 · 0 comments

Comments

@issadarkthing
Copy link

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);
  }
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant