The Multi-Threading procedures provide support for creating and handling multi-threaded applications. Threads allow creating of concurrent or parallel execution unit that uses CPU time slice. For multiple core machines the time slice can be allocated on different core leading to a true parallel execution of ATEasy code. Thread can speed execution, provide simpler coding when multiple tasks need to be executed at the same time. Thread often requires the use of ATEasy synchronization objects such as ASemaphore or ACriticalSection to serialize access to shared resources. In addition to the synchronization objects, ATEasy procedure has a Synchronize property that can be used to serialize the access to that procedure (one at a time) when called from multiple threads, See Procedure Properties for more information.
A “process” is an executing instance of an application. For example, when you double-click the Notepad icon, you start a process that runs Notepad.
A “thread” is a path of execution within a process. When you start Notepad, the operating system creates a process and begins executing the primary thread of that process. When this thread terminates, so does the process. This primary thread is supplied to the operating system by the startup code in the form of a function address. Usually, it is the address of the main or WinMain function that is supplied.
You can use CreateThread to create additional threads in your application if you wish. You may want to do this to handle background or maintenance tasks when you don’t want the user to wait for them to complete.
Special attention should be given to situations where more than one thread may require access to the same object. Writing and debugging multi-threaded programming is inherently a complicated and tricky undertaking, as you must ensure that objects are not accessed by more than one thread at a time.
|
||
|
||
|