标签:
//调度器
var list = Array();
var exc, cek;
var checkertime = 1000;
cek = checker(checkertime);
function checker(intervaltime) {
interval = setInterval(function () {
if (list.length > 0) {
clearInterval(cek);
exc = excutor(2);
console.log(‘on excutor‘);
} else {
console.log(‘off excutor‘);
}
}, intervaltime);
return interval;
}
function excutor(intervaltime) {
var interval = setInterval(function () {
if (list.length > 0) {
console.log(list.pop());
} else {
clearInterval(exc);
cek = checker(checkertime);
}
}, intervaltime);
return interval;
}
list.push(‘1‘);
var ddd = setInterval(function () {
list.push(‘2‘);
list.push(‘2‘); list.push(‘2‘); list.push(‘2‘); list.push(‘2‘); list.push(‘2‘); list.push(‘2‘);
clearInterval(ddd);
},10000);
标签:
原文地址:http://www.cnblogs.com/jacle169/p/5535714.html