source: [view]
var self=this;
this.state=t.threadStates.UNSTARTED;
this.priority=priority||t.threadPriorities.NORMAL;
this.lastError=null;
this.func=fn; // for lookup purposes.
this.invoke=function(){
self.state=t.threadStates.RUNNING;
try{
fn(this);
self.state=t.threadStates.COMPLETE;
}catch(e){
self.lastError=e;
self.state=t.threadStates.ERROR;
}
};