RAD Studio VCL Reference
ContentsIndex
PreviousUpNext
TCriticalSection Class

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

Pascal
TCriticalSection = class(TSynchroObject);
C++
class TCriticalSection : public TSynchroObject;

SyncObjs

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. 

 

TThread 

TCOMCriticalSection 

Using Critical Sections

Copyright(C) 2008 CodeGear(TM). All Rights Reserved.
What do you think about this topic? Send feedback!