Thread
classin packageklyn.threading
public class Thread extends Object implements Runnable:
Logical thread abstraction close to Java's `java.lang.Thread`.
This implementation keeps thread lifecycle semantics in Klyn while delegating
blocking primitives (`sleep` and `yield`) to the runtime.
Properties
| Modifier and Type |
Member |
Description |
| public static readonly property |
activeCount |
Returns the number of logically active threads. |
| public static readonly property |
currentThread |
Returns the current logical thread. |
| public readonly property |
id |
Unique thread id. |
| public readonly property |
isAlive |
Returns true while this thread is not terminated. |
| public readonly property |
isInterrupted |
Returns true when interruption was requested. |
| public property |
name |
Thread name. |
| public property |
priority |
Logical thread priority. |
| public readonly property |
state |
Current lifecycle state. |
Constructors
| Modifier and Type |
Member |
Description |
| public |
Thread |
Creates a thread with an auto-generated name derived from its unique id. |
| public |
Thread |
No summary. |
Methods
| Modifier and Type |
Member |
Description |
| public static |
current |
Java-like alias for `currentThread`. |
| public |
interrupt interrupt() as Void:
|
Marks the thread as interrupted. |
| public |
join join() as Void:
|
Waits for completion. |
| public |
joinjoin(timeoutMillis as Int) as Void: |
Waits up to a timeout in milliseconds. |
| public |
resume resume() as Void:
|
Resumes execution logically. |
| public override |
run run() as Void:
|
Runnable entrypoint. |
| public static |
sleepsleep(millis as Int) as Void: |
Puts the current thread to sleep. |
| public |
start start() as Void:
|
Starts the thread execution. |
| public |
stop stop() as Void:
|
Stops the thread logically. |
| public |
suspend suspend() as Void:
|
Suspends execution logically. |
| public override |
toString |
Returns a readable thread representation. |
| public static |
withTarget |
Creates a thread and binds a runnable target. |
| public static |
yield yield() as Void:
|
Provides a scheduler hint to yield execution. |