May Oakes
May Oakes

Reputation: 4629

Both threads blocking on call to boost::mutex::lock()

I have a boost::mutex that's being used in two threads. The first thread is constantly locking and unlocking the mutex. The second thread only uses the mutex on a certain condition. When this condition occurs, both threads block on the lock. What could possibly causing this?

Some random facts about my program: The mutex is a data member of class shared between the two threads. In the second thread, I am passing a pointer to the mutex to the function that uses it, but in the first thread I'm using the mutex by reference.

Upvotes: 0

Views: 267

Answers (1)

Mark B
Mark B

Reputation: 96301

Did you remember to unlock the mutex in the main thread after you signal the condition? Alternately, did you get into a deadlock situation?

Upvotes: 1

Related Questions