Boost Threads - Producer Consumer threads with synchronization
Your usage of the condition variable will probably work but is a-typical.

This is what you basically have:

while (1)
{
    boost::mutex::scoped_lock lock(m);      
    if (&lt;Test OK&gt;)
    {
        &lt;Do Work&gt;
        &lt;Notify Consumer&gt;
    }   
    else 
    {
        &lt;Wait for consumer to signal conditional&gt;
    }
}


Notice that here you lock the mutex m. If the test is not OK then you wait for the consumer to signal the condition variable. This releases the lock on m. Once the condition variable is signaled then your thread must wait to re-aquire the lock to continue. Once it does it releases the lock and then re-starts the loop which immediately try to re-aquire the lock.

A more typical pattern would be:

// pseudo code.
std::unique_ptr&lt;WORK&gt; getWork()
{
    boost::mutex::scoped_lock lock(m);      
    while(! &lt;Test OK&gt; )
    {
       &lt;Wait for consumer to signal conditional&gt;
    }
    return &lt;getWorkObjectFromQueue&gt;; 
}
.....
while(1)
{
    work = getWork();

    &lt;Do Work&gt;
    &lt;Notify Consumer&gt;
}


This way when you are waiting on the conditional variable and are signaled you do not have multiple attempts to re-acquire the lock before you do the work. As soon as you are signaled and have acquired the lock you can do a bit of work.