new TCThread(name, func, onErroropt)
One‑shot task executed on the shared cached thread pool. Supports cooperative
pause/resume/stop and exposes liveness/interruption flags for predictable coordination.
Examples
// Example: basic usage
var t = new TCThread("job1", () => delay(100));
t.start();
print(TCWait(t, 1000));
// Example: cooperative pause/resume
var t2 = new TCThread("pausable", (self) => {
for (var i=0;i<3;i++){
delay(60);
if (self.isPaused()) while (self.isPaused()) delay(40);
}
});
t2.start(t2);
t2.pause();
delay(150);
t2.resume();
print(TCWait(t2, 1000));
Parameters:
| string | name |
Logical name used in registries and for TCWait by name. |
|
| function | func |
User function executed when the thread starts. Arguments passed to |
|
| function | onError |
<optional> |
Optional non‑fatal error handler. |
getFunctionName() → {string}
Example
var t=new TCThread("p",()=>delay(500));
t.start();
print(t.getFunctionName());
Returns:
| string |
Logical name. |
| java.lang.Thread | null |
Underlying Java thread. |
| boolean |
| boolean |
Whether the thread is paused. |
| boolean |
Whether the thread is still running. |
| false |
Distinguish from virtual threads. |
| boolean |
True if interrupted path observed. |