在firefox(Aurora 30)中创建一个简单的线程时,这总会崩溃。
所有这一切都是从线程执行函数“任务”
知道出了什么问题?
function task(a, b) {
alert(a);
alert(b);
}
thread_job = {
init: function(func, param1, param2) {
this.func = func
this.param1 = param1
this.param2 = param2
alert("inside init");
},
run: function(){
this.func(this.param1, this.param2);
}
}
var thread = Components.classes["@mozilla.org/thread-manager;1"] // create thread
.getService(Components.interfaces.nsIThreadManager)
.newThread(0);
// init the object "thread_job" to a simple function
thread_job.init(task,1,2);
//extension code
thread.dispatch(thread_job, thread.DISPATCH_NORMAL);//dispatch the thread