Click to Rate and Give Feedback
MSDN
MSDN Library
System Services
Synchronization
 ReleaseMutex Function

  Switch on low bandwidth view
ReleaseMutex Function

Releases ownership of the specified mutex object.

Syntax

C++
BOOL WINAPI ReleaseMutex(
  __in  HANDLE hMutex
);

Parameters

hMutex [in]

A handle to the mutex object. The CreateMutex or OpenMutex function returns this handle.

Return Value

If the function succeeds, the return value is nonzero.

If the function fails, the return value is zero. To get extended error information, call GetLastError.

Remarks

The ReleaseMutex function fails if the calling thread does not own the mutex object.

A thread obtains ownership of a mutex either by creating it with the bInitialOwner parameter set to TRUE or by specifying its handle in a call to one of the wait functions. When the thread no longer needs to own the mutex object, it calls the ReleaseMutex function so that another thread can acquire ownership.

A thread can specify a mutex that it already owns in a call to one of the wait functions without blocking its execution. This prevents a thread from deadlocking itself while waiting for a mutex that it already owns. However, to release its ownership, the thread must call ReleaseMutex one time for each time that it obtained ownership (either through CreateMutex or a wait function).

Examples

For an example that uses ReleaseMutex, see Using Mutex Objects.

Requirements

Minimum supported clientWindows 2000 Professional
Minimum supported serverWindows 2000 Server
HeaderWinbase.h (include Windows.h)
LibraryKernel32.lib
DLLKernel32.dll

See Also

CreateMutex
Mutex Objects
Synchronization Functions

Send comments about this topic to Microsoft

Build date: 7/2/2009

Tags What's this?: Add a tag
Community Content   What is Community Content?
Add new content RSS  Annotations
vb.net syntax      dmex   |   Edit   |   Show History
<DllImport("kernel32.dll", SetLastError:=True)> _
Public Shared Function ReleaseMutex(ByVal handle As IntPtr) As Boolean
End Function
Flag as ContentBug
C# syntax      dmex   |   Edit   |   Show History
[DllImport("kernel32.dll", SetLastError=true)]
internal static extern bool ReleaseMutex(IntPtr handle);
Tags What's this?: c# (x) syntax (x) Add a tag
Flag as ContentBug
Processing
© 2009 Microsoft Corporation. All rights reserved. Terms of Use  |  Trademarks  |  Privacy Statement
Page view tracker