Jump to content

Mutex: Difference between revisions

16 bytes removed ,  14 years ago
m
→‎Win32: whitespace
m (→‎{{header|Java}}: Adding a throws for compilability)
m (→‎Win32: whitespace)
Line 69:
{{works with|Win32}}
To create a mutex operating system "object":
<lang c>HANDLE hMutex = CreateMutex(NULL, FALSE, NULL);</lang>
<lang c>
HANDLE hMutex = CreateMutex(NULL, FALSE, NULL);
</lang>
To lock the mutex:
<lang c>WaitForSingleObject(hMutex, INFINITE);</lang>
<lang c>
WaitForSingleObject(hMutex, INFINITE);
</lang>
To unlock the mutex
<lang c>ReleaseMutex(hMutex);</lang>
ReleaseMutex(hMutex);
</lang>
When the program is finished with the mutex:
<lang c>CloseHandle(hMutex);</lang>
CloseHandle(hMutex);
</lang>
 
===POSIX===
Anonymous user
Cookies help us deliver our services. By using our services, you agree to our use of cookies.