System.SyncObjs.TCriticalSection

From RAD Studio API Documentation
Jump to: navigation, search

System.SyncObjs.TSynchroObjectSystem.TObjectTCriticalSection

Delphi

TCriticalSection = class(TSynchroObject)

C++

class PASCALIMPLEMENTATION TCriticalSection : public TSynchroObject

Properties

Type Visibility Source Unit Parent
class public
System.SyncObjs.pas
System.SyncObjs.hpp
System.SyncObjs System.SyncObjs

Description

TCriticalSection allows a thread in a multithreaded application to temporarily block other threads from accessing a block of code.

Use TCriticalSection to safeguard operations that may be disrupted if another thread executes certain sections of code before the operation is completed. Critical sections work like gates that allow only a single thread to enter at a time. Because they block the execution of other threads, overusing critical sections can seriously interfere with performance.

Critical sections must be global in scope so that they are available to all threads. In every thread, any action that could interfere with the operations safeguarded by the critical section should only take place after calling the Acquire or Enter method. Threads that do not use the critical section for relevant operations can introduce bugs.

See Also

Code Examples