Skip to content

Instantly share code, notes, and snippets.

@ry
Created December 20, 2011 00:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ry/1499619 to your computer and use it in GitHub Desktop.
Save ry/1499619 to your computer and use it in GitHub Desktop.
var fs = require('fs');
var http = require('http');
function doStat(tid) {
fs.stat(__dirname, function(err, stat) {
if (err) throw err;
console.error('thread ' + tid, stat.mtime);
});
}
console.log("count: %d", process._countIsolate());
if (process.tid === 1) {
var isolate = process._newIsolate(process.argv);
//process._joinIsolate(isolate);
console.error("master");
doStat(1)
process.nextTick(function() {
doStat(1)
})
setTimeout(function() {
doStat(1)
}, 500);
console.log("thread 1 count: %d", process._countIsolate());
} else {
console.error("slave");
process.nextTick(function() {
doStat(2)
})
doStat(2)
setTimeout(function() {
doStat(2)
}, 500);
console.error("thread 2 count: %d", process._countIsolate());
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment