Thread Synchronization Objects
Two mechanisms discussed so far allow processes and threads to synchronize with one another.
- A thread running in a process can wait for another process to terminate, using ExitProcess, by waiting on the process handle using WaitForSingleObject or WaitForMultipleObjects. A thread can wait for another thread to terminate (ExitThread or return) in the same way.
- File locks are specifically for synchronizing file access.
There are risks inherent to the use of synchronization objects if they are not used properly. These risks, such as deadlocks, are described in this and subsequent chapters, along with techniques for developing reliable code. First, however, we'll show some synchronization examples in realistic situations.Two other synchronization objects, waitable timers and I/O completion ports, are deferred until Chapter 14. Both these objects require the Windows asynchronous I/O techniques described in that chapter.
