summaryrefslogtreecommitdiff
path: root/node_modules/webworker-threads/examples/quickIntro_multiThread.js
blob: 86e861e277fb2d3523b8f1fa6b881b35a3b7e665 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
function fibo (n) {
  return n > 1 ? fibo(n - 1) + fibo(n - 2) : 1;
}

var numThreads= 10;
var threadPool= require('webworker-threads').createPool(numThreads).all.eval(fibo);

threadPool.all.eval('fibo(35)', function cb (err, data) {
  process.stdout.write(" ["+ this.id+ "]"+ data);
  this.eval('fibo(35)', cb);
});

(function spinForever () {
  process.stdout.write(".");
  process.nextTick(spinForever);
})();