pthread_mutex_lock 文档:
If the mutex type is PTHREAD_MUTEX_RECURSIVE, then the mutex maintains the concept of a lock count. When a thread successfully acquires a mutex for the first time, the lock count is set to one. Every time a thread relocks this mutex, the lock count is incremented by one. Each time the thread unlocks the mutex, the lock count is decremented by one. When the lock count reaches zero, the mutex becomes available for other threads to acquire. If a thread attempts to unlock a mutex that it has not locked or a mutex which is unlocked, an error will be returned.
MSDN ReleaseMutex状态:
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).
等待函数等价于pthread_mutex_lock。
请参阅互斥对象 (Windows)以获取有关此 API 的更多详细信息。
而这个stackoverflow 条目可以查看 CRITICAL_SECTION 对象包含的内容。这将揭示 CRITICAL_SECTION 对象持有 - 除其他外 - 一个LockCount
允许递归使用的值。请参阅EnterCriticalSection 函数以了解此功能。