TThread class
Abstract Thread class.
Declaration
TThread = classDescends from it: TCompileWorkerThread TDaemonThread
Description
The TThread class encapsulates the native thread support of the
operating system. To create a thread, declare a descendant of the
TThread object and override the Execute method. In this method, the tthread's
code should be executed. To run a thread, create an instance of the tthread
descendant, and call it's execute method.
It is also possible to simply execute a method or static procedure in a thread using the ExecuteInThread class method.
See also
Properties
ReturnValue | protected | Return value of the thread when it stops executing. |
Terminated | protected | Indicates whether the Terminatemethod was called by the user. |
CurrentThread | public | Return current thread instance. |
Current | public | |
ProcessorCount | public | Return the processor count for this system. |
IsSingleProcessor | public | Is the current system single processor or not. |
FreeOnTerminate | public | Indicates whether the thread should free itself when it stops executing. |
Handle | public | Returns the thread handle. |
ExternalThread | public | Is the thread instance an external thread ? |
Priority | public | Returns the thread priority. |
Suspended | public | Indicates whether the thread is suspended. |
Finished | public | Has the thread finished executing. |
ThreadID | public | Returns the thread ID. |
FatalException | public | Exception that occurred during thread execution. |
Methods
DoTerminate | protected | Terminates the thread. |
TerminatedSet | protected | |
Execute | protected | Execute method. Must be overridden in a descendant thread. |
Synchronize | protected | Synchronizes the thread by executing the method in the main thread. |
Queue | protected | Queue a method for execution in the main thread. |
ForceQueue | protected | Always queue a method for execution in the main thread. |
Create | public | Creates a new thread. |
Destroy | public | Destroys the thread object. |
CreateAnonymousThread | public | Execute code in an anonymous thread. |
NameThreadForDebugging | public | Set a thread name. |
SetReturnValue | public | Set return value of a thread. |
CheckTerminated | public | Check if the current thread has finished executing. |
RemoveQueuedEvents | public | Remove methods scheduled for execution from queue. |
SpinWait | public | Prevent thread execution in a spin-wait loop. |
Sleep | public | Prevent thread execution. |
Yield | public | Yield execution to other threads. |
GetSystemTimes | public | Return CPU stats. |
GetCPUUsage | public | |
GetTickCount | public | Return tick count (32-bit). |
GetTickCount64 | public | Return tick count (64-bit). |
ExecuteInThread | public | Execute a method or static procedure in a thread. |
AfterConstruction | public | Code to be executed after construction but before execute. |
Start | public | Starts a thread that was created in a suspended state. |
Resume | public | Resumes the thread's execution. Deprecated, see TThread.Start. |
Suspend | public | Suspends the thread's execution. |
Terminate | public | Signals the thread it should terminate. |
WaitFor | public | Waits for the thread to terminate and returns the exit status. |
CurrentIsMain | public |
Events
OnTerminate | public | Event called when the thread terminates. |
Fields
FThreadID | protected |
Types and constants
TSystemTimes | public | Record for returning processor usage. |
An experiment, built from development snapshots. Not the official Free Pascal or Lazarus documentation.
