我想触发setTimeout回调函数,但是好像不行。有什么问题?
var fs = require("fs");
// set timeout callback
setTimeout(function(){
console.log("5000ms timeout");
process.exit(0);
}, 5000 );
// do something more than 5000ms
while(true) {
var stats = fs.statSync("foo");
console.log("while statement running...");
}
当我运行它时,5秒后,程序仍在运行