Thread
public javascript v1 · immutablefunction Thread(run){ this.run = run; // Similar to using Prototype's "bind" function // i.e. start = this.start.bind(this); var start = this.start; this.start = function(){ start.apply(self, arguments); };}Thread.prototype = { run: function() { return true; }, start: function() { this._stop = false; if (!this._stop && !this.run()) setTimeout(this.start, 0); return this; }, stop: function() { this._stop = true; return this; }};