Experimental Thread API.

Note that the debugger does not properly support threads at the moment.

Static methods

staticcreate(callb:() ‑> Void):Thread

Available on hl, neko, cpp, java

Creates a new thread that will execute the f function, then exit.

staticcreate(f:() ‑> Void):Thread

Available on macro

Creates a new thread that will execute the f function, then exit.

staticcurrent():Thread

Returns the current thread.

staticdelay(f:Float):Void

Available on macro

Suspends the execution of the calling thread for f seconds. The other program threads continue to run during this time.

staticexit():Void

Available on macro

Terminate prematurely the currently executing thread.

staticjoin(thread:Thread):Void

Available on macro

Suspends the execution of the calling thread until the thread thread has terminated.

staticreadMessage(block:Bool):Dynamic

Available on hl, neko, cpp, java

Reads a message from the thread queue. If block is true, the function blocks until a message is available. If block is false, the function returns null if no message is available.

staticreadMessage<T>(block:Bool):T

Available on macro

Reads a message from the thread queue. If block is true, the function blocks until a message is available. If block is false, the function returns null if no message is available.

staticself():Thread

Available on macro

Return the thread currently executing.

staticyield():Void

Available on macro

Re-schedule the calling thread without suspending it. This function can be used to give scheduling hints, telling the scheduler that now is a good time to switch to other threads.

Constructor

new(f:() ‑> Void)

Available on macro

Creates a new thread that executes function f.

Exceptions caused while executing f are printed to stderr and are not propagated to the parent thread.

Methods

id():Int

Available on macro

Return the identifier of the given thread. A thread identifier is an integer that identifies uniquely the thread. It can be used to build data structures indexed by threads.

kill():Int

Available on macro

Terminate prematurely the thread whose handle is given. This functionality is available only with bytecode-level threads.

sendMessage(msg:Dynamic):Void

Available on hl, neko, cpp, java

Send a message to the thread queue. This message can be read by using readMessage.

sendMessage<T>(msg:T):Void

Available on macro

Send a message to the thread queue. This message can be read by using readMessage.