function Thread(scope){
    var _timer=null;
    var _scope=null;
    var _interval=null;
    var _this = this;

    function set_scope(e){
        _scope=e;
    };

    function on_interval(){
        scope(_scope);
    };

    this.start=function(interval){
    	_interval = interval;
    	on_interval();
        _timer=setInterval(on_interval,interval);
    };

    this.stop=function(){
        clearInterval(_timer);
        _timer=null;
    };
    
    this.pause=function(timeout){
        _this.stop();
        setTimeout(function(){_this.start(_interval)},timeout);
    };

    this.update=function(e){
        set_scope(e);
    };
};