A synchronization object is an object whose handle can be specified in one of the wait functions to coordinate the execution of multiple threads. More than one process can have a handle to the same synchronization object, making interprocess synchronization possible.
The following object types are provided exclusively for synchronization.
Type | Description |
Event | Notifies one or more waiting threads that an event has occurred. For more information, see Event Objects. |
Mutex | Can be owned by only one thread at a time, enabling threads to coordinate mutually exclusive access to a shared resource. For more information, see Mutex Objects. |
Semaphore | Maintains a count between zero and some maximum value, limiting the number of threads that are simultaneously accessing a shared resource. For more information, see Semaphore Objects. |
Timer | Notifies one or more waiting threads that a specified time has arrived. For more information, see Waitable Timer Objects. |
Though available for other uses, the following objects can also be used for synchronization.
Object | Description |
Change notification | Created by the FindFirstChangeNotification function, its state is set to signaled when a specified type of change occurs within a specified directory or directory tree. For more information, see Files. |
Console input | Created when a console is created. The handle to console input is returned by the CreateFile function when CONIN$ is specified, or by the GetStdHandle function. Its state is set to signaled when there is unread input in the console's input buffer, and nonsignaled when the input buffer is empty. For more information about consoles, see Consoles and Character-Mode Support. |
Process | Created when a new process is created by calling the CreateProcess function. Its state is set to nonsignaled while the process is running, and signaled when the process terminates. For more information about processes, see Processes and Threads. |
Thread | Created when a new thread is created by calling the CreateProcess, CreateThread, or CreateRemoteThread function. Its state is set to nonsignaled while the thread is running, and signaled when the thread terminates. For more information about threads, see Processes and Threads. |
In some circumstances, you can also use a file, named pipe, or communications device as a synchronization object; however, their use for this purpose is discouraged. For additional information about I/O operations on files, named pipes, or communications, see Synchronization and Overlapped Input and Output.