public class Thread extends Object implements Runnable
Native thread with cooperative pause, interruption and stop requests.
Workers cooperate explicitly with Thread.checkpoint(). No checks are injected into ordinary loops, and a request never forcibly kills a worker.
def runWorker() as Void:
while Thread.checkpoint():
Thread.sleep(10)
worker = Thread(lambda(): runWorker())
worker.start()
worker.requestStop()
worker.join()| Modifier and Type | Member | Description |
|---|---|---|
| public static readonly property | activeCountactiveCount as UInt |
Returns the number of logically active threads. |
| public static readonly property | currentThreadcurrentThread as Thread |
Returns the current logical thread. |
| public readonly property | idid as ULong |
Unique thread id. |
| public readonly property | isAliveisAlive as Boolean |
Returns true between native startup and actual completion. |
| public readonly property | isInterruptedisInterrupted as Boolean |
Returns true when interruption was requested. |
| public property | namename as String |
Thread name. |
| public property | prioritypriority as String |
Requested native scheduling priority: LOWEST, LOW, NORMAL, HIGH or HIGHEST. |
| public readonly property | statestate as String |
Current lifecycle state. |
| public readonly property | stopRequestedstopRequested as Boolean |
Returns whether cooperative stopping was requested. |
| Modifier and Type | Member | Description |
|---|---|---|
| public | ThreadThread() |
Creates a thread with an auto-generated name derived from its unique id. |
| public | Thread | Creates a thread with the requested name. |
| public | Thread | Creates a thread that executes the supplied runnable. |
| public | Thread | Creates a named thread that executes the supplied runnable. |
| Modifier and Type | Member | Description |
|---|---|---|
| public static | checkpointcheckpoint() as Boolean |
Explicit cooperation point for the current thread. |
| public static | currentcurrent() as Thread |
Alias for currentThread. |
| public | interruptinterrupt() as Void |
Records interruption atomically and wakes an interruptible sleep. |
| public | joinjoin() as Void |
Waits for completion. |
| public | joinjoin(timeoutMillis as Int) as Void |
Waits up to a timeout in milliseconds. |
| public static | relinquishrelinquish() as Void |
Suggests that the scheduler let another ready thread execute. |
| public | requestStoprequestStop() as Void |
Requests cooperative stopping and wakes sleep or a paused checkpoint. |
| public | resumeresume() as Void |
Withdraws the pause request and wakes a paused worker. |
| public override | runrun() as Void |
Runnable entrypoint. |
| public static | sleepsleep(millis as Int) as Void |
Sleeps until the requested deadline, or an early stop/interruption. |
| public | startstart() as Void |
Starts the thread execution. |
| public | stopstop() as Void |
Compatibility alias for requestStop(); never forcibly kills a worker. |
| public | suspendsuspend() as Void |
Requests a cooperative pause, acknowledged at the next checkpoint. |
| public override | toStringtoString() as String |
Returns a readable thread representation. |