Static methods

staticcreate(?name:String, job:() ‑> Void, ?onExit:() ‑> Void, ?onAbort:Exception ‑> Void):Thread

Creates a new thread that will execute the job function, then exit after all events are processed. You can specify a custom exception handler onAbort or else Thread.onAbort will be called.

staticcurrent():Thread

Returns the current thread. If you are calling this function from a native thread that is not the main thread and was not created by Thread.create, this will return you a native thread with a null EvenLoop and isNative set to true. You need to call disposeNative() on such value on thread termination.

staticgetAll():Array<Thread>

Returns a list of all currently running threads. This excludes native threads which were created without Thread.create and have not been registered with a call to Thread.current().

staticinlinemain():Thread

Returns the main thread

staticonJobStart(f:() ‑> Void):Void

Registers f to be called when a thread is about to start executing its job.

staticreadMessage(blocking:Bool):Null<Dynamic>

Variables

read onlyevents:Null<EventLoop>

Deprecated: "Use haxe.EventLoop.getThreadLoop(thread) instead"

finalid:Int

@:value(true)isBlocking:Bool = true

Tells if we needs to wait for the thread to terminate before we stop the main loop (default:true).

read onlyisNative:Bool

Tells if a thread is a native thread that is not managed by Haxe. See Thread.current for details.

name:Null<String>

Allows to query or change the name of the thread. On some platforms this might allow debugger to identify threads.

Methods

dynamiconAbort(e:Exception):Void

This function is called when an uncaught exception aborted a thread. The error will be printed to stdout but this function can be redefined.

It is generally good practice to call any previously existing callback from functions assigned to this.

onExit(f:() ‑> Void):Void

Registers f to be called when the thread is exiting. In the case of an exception, it is called after onAbort.

It is not guaranteed to be called if the thread is killed in a way that does not lead to normal termination. Any callback assigned to this should not throw an exception.

onJobDone(f:() ‑> Void):Void

Registers f to be called once the thread has completed executing its job successfully. It is not called if the thread has thrown an exception.