// 2 объекта А, В, с эксклюзивным доступом
Mutex mtxA;
int nA=0;
Mutex mtxB;
int nB=0;
int threadA(...)
{
....
LockMutex(mtxA);
nA++;
...
LockMutex(mtxB); (**)
nB += nA;
UnlockMutex(mtxB);
UnlockMutex(mtxA);
...
}
int threadB(...)
{
LockMutex(mtxB);
// use nB;
..
LockMutex(mtxA); (**)
// use nB and nA
UnlockMutex(mtxА);
UnlockMutex(mtxB);
}