Reputation: 11
I'm trying to figure out whats wrong with this segment of code? I've been studying it for a while and I still cannot see any dead-lock if there is one. Any hints would be greatly appreciated!
Mutex mA;
Mutex mB;
Take(mA);
Take(mB);
DoSomething();
Release(mA);
Release(mB);
Upvotes: 1
Views: 80
Reputation: 129524
This code on it's own will not cause a problem. But if you have code that uses the reverse Take(mB); Take(mA);
somewhere else, you can get a deadlock.
Upvotes: 2