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

TThread

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

Abstract Thread class.

Declaration

Source position: classesh.inc line 1565

type TThread = class end;

public

Type

  TSystemTimes = record

  

Record for returning processor usage

  IdleTime: QWord;

  

Processor idle time

  UserTime: QWord;

  

User code execution time

  KernelTime: QWord;

  

Kernel (OS) code execution time

  NiceTime: QWord;

  

Nice (reduced priority) code execution time

end;

protected

  procedure Execute; virtual; abstract;

  

Execute method. Must be overridden in a descendent thread.

  procedure Synchronize();

  

Synchronizes the thread by executing the method in the main thread.

  procedure Queue();

  

Queue a method for execution in the main thread

public

  constructor Create();

  

Creates a new thread.

  destructor Destroy; override;

  

Destroys the thread object.

  class function CreateAnonymousThread();

  

Execute code in an anonymous thread

  class procedure NameThreadForDebugging();

  

Set a thread name

  class procedure SetReturnValue();

  

Set return value of a thread

  class function CheckTerminated;

  

Check if the current thread has finished executing.

  class procedure RemoveQueuedEvents();

  

Remove methods scheduled for execution from queue

  class procedure SpinWait();

  

Prevent thread execution in a spin-wait loop

  class procedure Sleep();

  

Prevent thread execution

  class procedure Yield;

  

Yield execution to other threads

  class procedure GetSystemTimes();

  

Return CPU stats

  class function GetTickCount; deprecated ;

  

Return tick count (32-bit)

  class function GetTickCount64;

  

Return tick count (64-bit)

  procedure AfterConstruction; override;

  

Code to be executed after construction but before execute.

  procedure Start;

  

Starts a thread that was created in a suspended state.

  procedure Resume; deprecated ;

  

Resumes the thread's execution. Deprecated, see TThread.Start

  procedure Suspend; deprecated ;

  

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 CurrentThread: TThread; [r]

  

Return current thread instance

  property ProcessorCount: LongWord; [r]

  

Return the processor count for this system

  property IsSingleProcessor: Boolean; [r]

  

Is the current system single processor or not

  property FreeOnTerminate: Boolean; [rw]

  

Indicates whether the thread should free itself when it stops executing.

  property Handle: TThreadID; [r]

  

Returns the thread handle.

  property ExternalThread: Boolean; [r]

  

Is the thread instance an external thread ?

  property Priority: TThreadPriority; [rw]

  

Returns the thread priority.

  property Suspended: Boolean; [rw]

  

Indicates whether the thread is suspended.

  property Finished: Boolean; [r]

  

Has the thread finished executing

  property ThreadID: TThreadID; [r]

  

Returns the thread ID.

  property OnTerminate: TNotifyEvent; [rw]

  

Event called when the thread terminates.

  property FatalException: TObject; [r]

  

Exception that occured during thread execution

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 tthread'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. Must be overridden in a descendent thread.


Documentation generated on: Nov 16 2015