Other locking mechanisms

Critical sections are not the only mechanism that operating systems expose to applications. There are also other approaches that may be preferable in different situations. In Delphi, most of them are nicely wrapped into system-independent wrappers, implemented in the System.SyncObjs unit.

The first such object is a mutex. It is very similar to a critical section, as you can use it to protect access to a critical resource. The big difference between a mutex and a critical section is that a critical section can only be shared between the threads of one program. A mutex, on other hand, can have a name. Two (or more) programs can create mutexes with the same name and use them to access some shared resource (for example, ...

Get Mastering Delphi Programming: A Complete Reference Guide now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.