For more details, refer to: http://www.cnblogs.com/xumenger/p/4450659.html
or refer to the blog after
Four system kernel objects (events, mutexes, signals, timers) are the means of thread synchronization, which also shows the complexity of handling thread synchronization, but this is not all, and Windows Vista is beginning to add Condition variables (condition variables), Slim Reader-writer Locks (read-write lock) and other synchronization means.
However, the simplest and lightest (fastest) synchronization is criticalsection (critical section), but it does not belong to the system kernel object, and of course there is no handle, no tsecurityattributes This security attribute, which also causes it to not be used across processes, However, it is generally not necessary to cross-process when writing multi-threading, so criticalsection should be the most common means of synchronization.
I think it is necessary to understand this at this point: This attribute is generally present when building system kernel objects (tsecureattributes)
In the next multi-threaded subject to use some kernel objects, it is better to check the first, then encounter this attribute to give a nil, no need to bother.
Building events
function CreateEvent ( lpeventattributes:psecurityattributes; {!} Bmanualreset:bool; Binitialstate:bool; Lpname:pwidechar): Thandle; stdcall;
Creating mutexes
function CreateMutex ( lpmutexattributes:psecurityattributes; {!} Binitialowner:bool; Lpname:pwidechar): Thandle; stdcall;
Signal creation
function CreateSemaphore ( lpsemaphoreattributes:psecurityattributes; {!} Linitialcount:longint; Lmaximumcount:longint; Lpname:pwidechar): Thandle; stdcall;
Setting up a wait timer
function CreateWaitableTimer ( lptimerattributes:psecurityattributes; {!} Bmanualreset:bool; Lptimername:pwidechar): Thandle; stdcall;
The above four system kernel objects (events, mutexes, signals, timers) are the means of thread synchronization, which can also be seen to handle the complexity of thread synchronization, but this is not all, Windows Vista began to add Condition variables (condition variable), Slim Reader-writer Locks (read-write lock) and other synchronization means.
However, the simplest and lightest (fastest) synchronization is criticalsection (critical section), but it does not belong to the system kernel object, and of course there is no handle, no tsecurityattributes This security attribute, which also causes it to not be used across processes, However, it is generally not necessary to cross-process when writing multi-threading, so criticalsection should be the most common means of synchronization.
Methods of Delphi Thread synchronization