代码如下 var tSql = "select * from " + this.config.table + " limit 1,2"; var onlock = false; var lock = true; var date = new Date();
var caller = model.caller; while(lock && (new Date().getTime()-date.getTime()<10000)) { if(!onlock) { this.connection.query(tSql,function(err,rows,fields){ console.log(rows); console.log(“finish”); console.log(lock); console.log(onlock); lock = false; caller.propertys = 123; }); onlock = true; } }
需求:希望query完成后结束while 实际情况:在while那里卡住,经过10秒钟后才进入回调函数
6 回复