function Observer() {
function unique(arr) {
let newArr = [arr[0]];
for (let i = 1; i < arr.length; i++) {
let flag = false;
for (var j = 0; j < newArr.length; j++) {
if (arr[i] == newArr[j]) {
flag = true;
break;
}
}
if (!flag) {
newArr.push(arr[i]);
}
}
return newArr;
}
currentActis = new Array();
for (let c = 0; c < 100; c++) {
sleep(500);
currentActis[c] = currentActivity();
}
ac = unique(currentActis);
if (ac.length == 1) {
return false
}
return true
}
// 》》》》》》》》》》》》》》》》》》》 START
work_thread = threads.start(function () {
Main();
});
observer_thread = threads.start(function () {
while (true) {
sleep(5000);
if (!Observer()) {
work_thread.interrupt();
work_thread = threads.start(function () {
console.setPosition(device.width / 2, device.height / 1.5);
console.show();
console.warn("Main线程在5秒后重启!");
sleep(5000);
console.hide();
Main();
});
}
}
});