Subj : Re: recursive mutexes To : comp.programming.threads,comp.unix.programmer From : David Hopwood Date : Thu May 19 2005 01:31 am David Schwartz wrote: > red floyd wrote: > >>May I ask why? > > There are two possibilities: > > 1) You don't know the mutex is being used recursively. In this case, the > recursive mutex will hide a serious problem. > > 2) You know the mutex is being recursively. In this case, just don't > lock it since you know it's already locked anyway. It is sometimes the case that you have code which can usefully be called either with the mutex already held or with it not already held. This happens in particular when you have an object protected by a mutex, and some method of that object can potentially take the same object as an argument. It's not a very common case, admittedly. -- David Hopwood .