worker.js 429 B

12345678910111213141516171819202122
  1. // DEBUG=* node example/worker
  2. // DEBUG=worker:* node example/worker
  3. // DEBUG=worker:a node example/worker
  4. // DEBUG=worker:b node example/worker
  5. var a = require('../')('worker:a')
  6. , b = require('../')('worker:b');
  7. function work() {
  8. a('doing lots of uninteresting work');
  9. setTimeout(work, Math.random() * 1000);
  10. }
  11. work();
  12. function workb() {
  13. b('doing some work');
  14. setTimeout(workb, Math.random() * 2000);
  15. }
  16. workb();