TCThread

tcThreadManager~ TCThread

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
TCThread#start are forwarded to this function.

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.

getJavaThread() → {java.lang.Thread|null}

Example
var t=new TCThread("p",()=>delay(500));
t.start();
var jt=t.getJavaThread();
Returns:
java.lang.Thread | null

Underlying Java thread.

isAlive() → {boolean}

Check liveness (includes short "starting" window).

Example
var t=new TCThread("p",()=>delay(500));
t.start();
print(t.isAlive());
Returns:
boolean

isPaused() → {boolean}

Example
var t=new TCThread("p",()=>delay(500));
t.start();
print(t.isPaused());
Returns:
boolean

Whether the thread is paused.

isRunning() → {boolean}

Example
var t=new TCThread("p",()=>delay(500));
t.start();
print(t.isRunning());
Returns:
boolean

Whether the thread is still running.

isVirtual() → {false}

Example
var t=new TCThread("p",()=>delay(500));
t.start();
print(t.isVirtual()); // false
Returns:
false

Distinguish from virtual threads.

join()

Blocking join; prefer TCWait with timeout.

Example
var t=new TCThread("p",()=>delay(500));
t.start();
t.join();

pause()

Request cooperative pause.

Example
var t=new TCThread("p",()=>delay(500));
t.start();
t.pause();

resume()

Resume after a cooperative pause.

Example
var t=new TCThread("p",()=>delay(500));
t.start();
t.resume();

start()

Start execution exactly once. Additional calls are ignored.
Arguments are forwarded to the user function.

Example
// Example: start twice (second call is ignored)
var t = new TCThread("once", () => delay(10));
t.start();

stop()

Signal the thread to stop and attempt to interrupt/cancel underlying Java thread.

Example
// Example: stop a long task early
var t = new TCThread("willStop", () => delay(2000));
t.start();
delay(100);
t.stop();
print(TCWait(t, 300)); // usually false

wasInterrupted() → {boolean}

Example
var t=new TCThread("p",()=>delay(500));
t.start();
print(t.wasInterrupted());
Returns:
boolean

True if interrupted path observed.