API:Datasnap.DSSession.TDSLocalServer

From RAD Studio API Documentation

TDSLocalServerSystem.Classes.TThreadSystem.TObject

Delphi

TDSLocalServer = class(TThread)

C++

class PASCALIMPLEMENTATION TDSLocalServer : public System::Classes::TThread

Properties

Type Visibility Source Unit Parent
class public
Datasnap.DSSession.pas
Datasnap.DSSession.hpp
Datasnap.DSSession Datasnap.DSSession

Description

TThread is an abstract class that enables creation of separate threads of execution in an application. {{#multireplace:Datasnap.DSSession.TDSLocalServer|H21=!|H25=%|H28=(|H29=)|H2A=*|H2B=+|H2F=/|H3C=<|H3D==|H3E=>|H5B=[|H5D=]|H5E=^|H7C=|}} inherits from {{#multireplace:System.Classes.TThread|H21=!|H25=%|H28=(|H29=)|H2A=*|H2B=+|H2F=/|H3C=<|H3D==|H3E=>|H5B=[|H5D=]|H5E=^|H7C=|}}. All content below this line refers to {{#multireplace:System.Classes.TThread|H21=!|H25=%|H28=(|H29=)|H2A=*|H2B=+|H2F=/|H3C=<|H3D==|H3E=>|H5B=[|H5D=]|H5E=^|H7C=|}}.

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