From RAD Studio API Documentation
Jump to: navigation, search



TTransportThread = class(TThread)


class PASCALIMPLEMENTATION TTransportThread : public System::Classes::TThread


Type Visibility Source Unit Parent
class public
Datasnap.Win.SConnect Datasnap.Win.SConnect


TThread is an abstract class that enables creation of separate threads of execution in an application.

Datasnap.Win.SConnect.TTransportThread inherits from System.Classes.TThread. All content below this line refers to System.Classes.TThread.

TThread is an abstract class that enables creation of separate threads of execution in an application.

Create a descendant of TThread to represent an execution thread in a multithreaded application. Each new instance of a TThread descendant is a new thread of execution. Multiple instances of a TThread derived class make an application multithreaded.

When an application is run, it is loaded into memory ready for execution. At this point it becomes a process containing one or more threads that contain the data, code and other system resources for the program. A thread executes one part of an application and is allocated CPU time by the operating system. All threads of a process share the same address space and can access the process's global variables.

Use threads to improve application performance by:

  • Managing input from several communication devices.
  • Distinguishing among tasks of varying priority. For example, a high priority thread handles time-critical tasks, and a low priority thread performs other tasks.

Following are issues and recommendations to be aware of when using threads:

  • Keeping track of too many threads consumes CPU time; the recommended limit is 16 active threads per process on single processor systems.
  • When multiple threads update the same resources, they must be synchronized to avoid conflicts.
  • Most methods that access an object and update a form must only be called from within the main thread or use a synchronization object such as TMultiReadExclusiveWriteSynchronizer.

Define the thread object's Execute method by inserting the code that should execute when the thread is executed.

See Also

Code Examples and Samples