Class Thread
Inheritance
Object | Thread 🡄 Object |
Properties
Finished | Returns true if the thread has reached the end. |
Terminated | Returns true if the Terminate method has been called. |
name | This name will be shown when the thread terminated abnormally. |
Methods
freeOnTerminate ( state ) | When set to true the thread object will free itself when the function ends. |
resume () | Resume the thread's execution. |
suspend () | Suspend the thread's execution. |
synchronize ( func ) | This wil cause the tread to get the main thread to execute the given function and wait for it to finish. |
terminate () | Tells the thread it should terminate. |
waitfor () | Waits for the given thread to finish. |
Creation
createThread ( func ) | Executes the given function in another thread using the systems thread mechanism. |
createThreadSuspended ( func ) | Same as createNativeThread but it won't run until resume is called on it. |
Inheritance
Properties
- Finished
-
Returns true if the thread has reached the end.
Do not rely on this if the thread is freeOnTerminate(true) (which is the default).
Type:
boolean - Terminated
-
Returns true if the Terminate method has been called.
Type:
boolean - name
-
This name will be shown when the thread terminated abnormally.
Type:
Methods
- freeOnTerminate ( state )
-
When set to true the thread object will free itself when the function ends.
(default=true) Note: Use this only from inside the thread function as the thread might have already terminated and freed itself when called.
Parameters:
- state
- resume ()
- Resume the thread's execution.
- suspend ()
- Suspend the thread's execution.
- synchronize ( func )
-
This wil cause the tread to get the main thread to execute the given function and wait for it to finish.
Called from inside the thread.
Usually for GUI access Returns the return value of the given function
Parameters:
- func function
Usage:
Thread.synchronize(function(thread, ...), ...)
- terminate ()
- Tells the thread it should terminate. The Terminated property will become true.
- waitfor ()
-
Waits for the given thread to finish.
(Not recommended to call this from inside the thread itself)
Creation
- createThread ( func )
-
Executes the given function in another thread using the systems thread mechanism.
The function returns the Thread class object
function declaration: function (Thread, ...)
Parameters:
- func function
Usage:
thread = createThread(function(Thread, ...), ...)
- createThreadSuspended ( func )
-
Same as createNativeThread but it won't run until resume is called on it.
Parameters:
- func function
Usage:
thread = createThreadSuspended(function(Thread, ...), ...)