Aztec® Programming Language
Version 1.1 Alpha 2

Copyright © 2010-2017, Aztec Development Group, All Rights Reserved

Download Aztec

Search        Contact Us

Let the music keep our spirits high.

- Jackson Browne

 

The ‘Thread’ class is used to represent a single thread of execution within the Virtual Machine.  It is an abstract class defined in the ‘aztec.system’ space. The Thread class provides the programmer with a wealth of functionality to query and control the VM thread's operation, including Thread Status Control, Message Handling between Threads, Handling Exceptions and Event Processing. And with the SyncLock and SyncFlag classes, synchronization between the threads is easily controlled.

♦ Any number of separate threads of execution can be created within an Aztec script/application. Each VM thread is tied to its own separate underlying operating system thread, and the thread can be fully controlled by the script.

♦ The Thread class is an abstract class, so a user defined class must be created with Thread as its base class. The user defined class must override the abstract Run() method.

Thread Class Hierarchy

 

♦ The Virtual Machine creates the main thread of execution automatically.

♦ If a Main class is used and is derived from Thread, the VM instantiates the user defined Thread object automatically and invokes the “Run()” method within the context of the main VM thread.

♦ If a Main method is used (shared or global), the VM invokes “Main()” within the context of the main thread.

♦ There are two methods in the 'Script' class and two global methods to get the ‘Thread’ reference to the current thread and the main thread.

Script Methods

♦ public  method<Thread>  Thread()
♦ public  method<Thread>  MainThread()

Global Methods

♦ public  method<Thread>  GetThread()
♦ public  method<Thread>  GetMainThread()

♦ If multiple threads are used, there are several ways to control or synchronize the execution of one thread relative to another, which is oftentimes useful for ensuring only one thread accesses a resource at a time. The Using Multiple Threads page desribes these capabilities in more detail.

The following table shows some of the key methods in the Thread class.

Key Methods of the Thread Class

 

Page UpPage DownCopyright © 2010-2017
Aztec Development Group
All Rights Reserved

Download Aztec