From RAD Studio API Documentation
Jump to: navigation, search



TCriticalSection = class(TSynchroObject)


class PASCALIMPLEMENTATION TCriticalSection : public TSynchroObject


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


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