/**
* class : threader
* summary : 线程对象
* version : 1.0(2005.11.1)
* author : Frank
*/
class threader {
////初试时间,也就是间隔时间
public var th_start_time;
////运行几次
private var th_run_times;
////当前运行次数
private var th_now_times = 0;
////th_name,线程名
private var th_name;
////th_controller,辅助控制者
private var th_controller;
///任务
public var th_task;
///路径
public var th_task_route;
public var th_group = new Array();
function threader() {
}
public function do_task(param1, param2, param3, param4):Void {
th_start_time = param1;
th_task_route = param2;
th_task = param3;
th_run_times = param4;
th_now_times = 0;
this.th_name = setInterval(th_task_route, th_task, th_start_time);
////开起当前线程控制
setup_controller();
}
//清除任务
private function clear_task():Void {
th_now_times++;
if (th_now_times == th_run_times) {
//清除当前线程
clearInterval(this.th_name);
//调用关闭线程控制
endup_controller();
}
}
private function setup_controller():Void {
////开起线程控制
this.th_controller = setInterval(this, "clear_task", th_start_time);
}
private function endup_controller():Void {
////关闭线程控制
clearInterval(this.th_controller);
}
}
用法:
以下是引用片段: |
回复Comments
作者:
{commentrecontent}