Package Exports
- uupaa.thread.js
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (uupaa.thread.js) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
Thread.js 
Thread and ThreadPool functions.
Document
How to use
Browser
// thread.html
<script src="lib/Thread.js"></script>
<script>
var thread = new Thread("worker-thread.js", function(event) {
console.log(event.data); // "HELLO WORLD"
thread.close();
}, function(exitCode, errorMessage) {
switch (exitCode) {
case Thread.OK: // 0
console.log("Safely closed.");
break;
case Thread.ERROR: // 1
console.log("Terminates with an error from WorkerThread. " + errorMessage);
break;
case Thread.FORCE: // 2
console.log("Forced termination by user.");
break;
case Thread.TIMEOUT: // 3
console.log("Watchdog barked.");
break;
}
});
thread.post("HELLO");
</script>
WebWorkers
// worker-thread.js
importScripts("lib/Thread.js");
var thread = new Thread("", function(event) {
thread.post(event.data + " WORLD");
}, function(ready, cancel) {
// .... destruction process...
ready(); // -> WORKER_CLOSE_READY
//cancel(); // -> WORKER_CLOSE_CANCEL
});