Multi-thread synchronization process between the three methods

three methods:

1, mutex object

2, the event object

3, the key code

Comparison of three:

Mutex object and event objects are kernel objects, thread synchronization using the kernel object, slower, but use mutex objects and events such as kernel objects, can be synchronized between multiple processes in various threads.

The key code section is working in user mode, synchronous speed, but when using critical sections of code, it is easy to enter a deadlock state, because they can not set the timeout value while waiting to enter the critical section.

Initialization critical objects in the constructor, destructor left call resource enter, after the call leave.

Guess you like

Origin www.cnblogs.com/asce/p/11111067.html