зеркало из https://github.com/mozilla/pluotsorbet.git
39 строки
906 B
JavaScript
39 строки
906 B
JavaScript
/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
|
/* vim: set shiftwidth=4 tabstop=4 autoindent cindent expandtab: */
|
|
|
|
'use strict';
|
|
|
|
var Thread = function(name) {
|
|
if (this instanceof Thread) {
|
|
this.name = name || "noname";
|
|
this.priority = (Thread.MAX_PRIORITY + Thread.MIN_PRIORITY) >> 1;
|
|
this.stack = new Stack();
|
|
} else {
|
|
return new Thread(name);
|
|
}
|
|
}
|
|
|
|
Thread.prototype.setName = function(name) {
|
|
this.name = name;
|
|
}
|
|
|
|
Thread.prototype.getName = function(name) {
|
|
return this.name;
|
|
}
|
|
|
|
Thread.MIN_PRIORITY = 0;
|
|
Thread.MAX_PRIORITY = 100;
|
|
|
|
Thread.prototype.setPriority = function(priority) {
|
|
this.priority = priority;
|
|
}
|
|
|
|
Thread.prototype.getPriority = function() {
|
|
return this.priority;
|
|
}
|
|
|
|
Thread.prototype.startMain = function(entryPoint, args) {
|
|
this.stack.push(null); // args
|
|
entryPoint.run(this.stack);
|
|
}
|