Thread
classin packageklyn.threading
public class Thread extends Object implements Runnable:
└ Thread
All Implemented Interfaces: 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
activeCount as UInt:
Returns the number of logically active threads.
public static readonly property currentThread
currentThread as Thread:
Returns the current logical thread.
public readonly property id
id as ULong:
Unique thread id.
public readonly property isAlive
isAlive as Boolean:
Returns true while this thread is not terminated.
public readonly property isInterrupted
isInterrupted as Boolean:
Returns true when interruption was requested.
public property name
name as String:
Thread name.
public property priority
priority as String:
Logical thread priority.
public readonly property state
state as String:
Current lifecycle state.
Properties inherited from Object: type
Constructors
Modifier and Type Member Description
public Thread Creates a thread with an auto-generated name derived from its unique id.
public Thread
Thread(name as String):
No summary.
Methods
Modifier and Type Member Description
public static current
current() as Thread:
Java-like alias for `currentThread`.
public interrupt
interrupt() as Void:
Marks the thread as interrupted.
public join
join() as Void:
Waits for completion.
public join
join(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 sleep
sleep(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
toString() as String:
Returns a readable thread representation.
public static withTarget
withTarget(name as String, target as Runnable) as Thread:
Creates a thread and binds a runnable target.
public static yield
yield() as Void:
Provides a scheduler hint to yield execution.
Methods inherited from Object: fromJson, toDict, toJson, toString, toXml
Methods inherited from Runnable: run