Subj : Re: Recursive mutexes To : comp.programming.threads From : David Schwartz Date : Thu Mar 24 2005 04:04 pm "notme" wrote in message news:3aeb79F6854tsU1@individual.net... > void my_mutex::acquire() { > EnterCriticalSection(); > if (m_owner == thread_id) { > ++m_count; > } > else { > m_mutex->wait(); Why are you waiting for the mutex while holding the critical section? How will the thread that holds the mutex release it? > m_count = 1; > m_owner = thread_id; > } > ExitCriticalSection(); > } Also, your code won't work unless thread IDs are unique in the sense that the same thread can't have more than one of them. This is true on most platforms unless you are using thread handles instead of thread identifiers. DS .