It deadlocks itself: the second lock call blocks waiting for a mutex that only the same blocked thread could release.
A recursive (reentrant) mutex tracks the owner and a count, allowing the same thread to lock it repeatedly and requiring the same number of unlocks.
Prefer restructuring code so locks are not needed recursively, because reentrant locks can hide design problems.
Loading…