[Overview][Constants][Types][Classes][Procedures and functions][Variables] | Reference for unit 'Classes' (#fcl)

# TThread

[Properties (by Name)] [Methods (by Name)] [Events (by Name)]

Abstract Thread class.

## Declaration

`type TThread = class`
`protected`
`procedure DoTerminate; virtual;` |  | Terminates the thread.
`procedure Execute; virtual; abstract;` |  | Execute method. Should be overridden in a descendent thread.
`procedure Synchronize();` |  | Synchronizes the thread by executing the method in the main thread.
`property ReturnValue: Integer; [rw]` |  | Return value of the thread when it stops executing.
`property Terminated: Boolean; [r]` |  | Indicates whether the Terminatemethod was called by the user.
`public`
`FStackPointer: Integer;` |  |
`FStackSize: Integer;` |  |
`FCallExitProcess: Boolean;` |  |
`constructor Create();` |  | Creates a new thread.
`destructor Destroy; override;` |  | Destroys the thread object.
`procedure Resume;` |  | Resumes the thread's execution.
`procedure Suspend;` |  | Suspends the thread's execution.
`procedure Terminate;` |  | Signals the thread it should terminate.
`function WaitFor;` |  | Waits for the thread to terminate and returns the exit status.
`property FreeOnTerminate: Boolean; [rw]` |  | Indicates whether the thread should free itself when it stops executing.
`property Handle: THANDLE; [r]` |  | Returns the thread handle.
`property Priority: TThreadPriority; [rw]` |  | Returns the thread priority.
`property Suspended: Boolean; [rw]` |  | Indicates whether the thread is suspended.
`property ThreadID: THANDLE; [r]` |  | Returns the thread ID.
`property OnTerminate: TNotifyEvent; [rw]` |  | Event called when the thread terminates.
`end;`

## Inheritance

`TThread` |  | Abstract Thread class.
`TObject`

## Description

The TThread class encapsulates the native thread support of the operating system. To create a thread, declare a descendent of the TThread object and override the Execute method. In this method, the thhread's code should be executed. To run a thread, create an instance of the tthread descendent, and call it's execute method.

## See also

EThread |  | Thread error exception.
TThread.Execute |  | Execute method. Should be overridden in a descendent thread.