blob: 4749c144bd3c1bcc30134034d6ed903e8521df5f (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
|
var Thread= require('webworker-threads');
function cb (e,m) {
this.ctr= this.ctr ? this.ctr+1 : 1;
console.log('['+ this.id+ '] -> '+ this.ctr);
if (this.ctr >= 9) this.destroy();
else this.eval('0', cb);
}
var i= +process.argv[2] || 1;
console.log('Using '+ i+ ' threads');
while (i--) {
Thread.create().eval('0', cb);
}
process.on('exit', function () {
console.log("process.on('exit') -> BYE!");
});
|