class PThread |
This class defines a thread of execution in the system.
Run Time Type functions
I/O functions
Comparison functions
This class defines a thread of execution in the system. A thread is an independent flow of processor instructions. This differs from a process which also embodies a program address space and resource allocation. So threads can share memory and resources as they run in the context of a given process. A process always contains at least one thread. This is reflected in this library by the PProcess class being descended from the PThread class.The implementation of a thread is platform dependent, but it is assumed that the platform has some support for native threads. Previous versions of PWLib has some support for co-operative threads, but this has been removed
Note that the exact timing of the execution of code in threads can never be predicted. Thus you you can get a race condition on intialising a descendent class. To avoid this problem a thread is always started suspended. You must call the Resume() function after your descendent class construction is complete.
If synchronisation is required between threads then the use of semaphores is essential.
If the deletion is set to AutoDeleteThread then the PThread is assumed to be allocated with the new operator and may be freed using the delete operator as soon as the thread is terminated or executes to completion (usually the latter).
The stack size argument retained only for source code compatibility for previous implementations. It is not used in the current code and may be removed in subsequent versions.
Note that the correct way for a thread to terminate is to return from the Main() function.
If the thread is still running then this function is ignored.
Note that the correct way for a thread to terminate is to return from the Main() function or self terminate by calling Terminate() within the context of the thread which can then assure that all resources are cleaned up.
If susp is TRUE this increments an internal count of suspensions that must be matched by an equal number of calls to Resume() or Suspend(FALSE) before the thread actually executes again.
If susp is FALSE then this decrements the internal count of suspensions. If the count is <= 0 then the thread will run. Note that the thread will not be suspended until an equal number of Suspend(TRUE) calls are made.
Note that the correct way for a thread to terminate is to return from this function.
This may not be implemented on all platforms.
Alphabetic index HTML hierarchy of classes or Java