Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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
You can’t perform that action at this time.