📄 thread.js
字号:
// Description: js.lang.Thread 线程类
// Author: Changhua.Wan
// Version: 2004.03.06.01
_package("js.lang");
_import("js.lang.Object");
function js.lang.Thread(_func, _delay) {
js.lang.Thread._base.call(this);
this.func = _func;
this.delay = 1000;
if (typeof(_delay) == "number") this.delay = _delay;
var _handle = null;
this.start = function() {
if (_handle != null) return;
_handle = window.setInterval("window." + this.getUID() + ".run()", this.delay);
}
this.sync = false;
this.run = function() {
if (this.sync) return;
this.sync = true;
if (typeof(this.func) == "function") this.func();
this.sync = false;
}
this.stop = function() {
window.clearInterval(_handle);
_handle = null;
}
}
var _p = js.lang.Thread._extends("js.lang.Object");
var _c = js.lang.Thread;
_c.sleep = function(_ms) {
var _ss = new Date().getTime();
while(true) {
if (new Date().getTime() - _ss > _ms) return;
try {
var xmldom = new ActiveXObject("Microsoft.XMLDOM");
xmldom.async = false;
xmldom.load("about:blank");
//TODO ..
} catch(ex) {}
}
};
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -