LockMutex()

Syntax

LockMutex(Mutex)
Description
Waits until the mutex object is available (not locked by another thread) and then locks the object so no other thread can get a lock on the object.

After this function returns, it is assured that this thread is the only one with a locked state on the mutex. The thread can now freely access the shared resource that is protected by this mutex, as it is the only one with exclusive access to the mutex.

If another thread calls LockMutex() while this one has the lock, it will wait inside the LockMutex() function until this thread calls UnlockMutex() to release its lock on the mutex.

Note: Since the LockMutex() function waits until the mutex is available, it can easily lead to lockup situations if a UnlockMutex() call is forgotten.

See CreateMutex() for a code example.

Parameters

Mutex The mutex to lock.

Return value

None.

See Also

UnlockMutex(), CreateMutex()

Supported OS

All

<- KillThread() - Thread Index - PauseThread() ->