Boost logo

Boost Users :

Subject: [Boost-users] Threading question
From: Davies, John (john.davies_at_[hidden])
Date: 2013-09-26 19:16:54

I have the following code and it terminates as expected. When I call the destructor it interrupts the thread.

But if I change the this_thread::sleep to this_thread::yield the join() never happens and the program hangs.

I must be misunderstanding yield. But I really don't want a sleep if possible.


    // Terminate the thread
    delete pMessageQueueInputThread;
void MessageQueueHandler::MessageQueueInputThread()
    unsigned int receivedSize;
    unsigned int priority;
    char buffer[queueMaximumMessageSize];
            // Process all messages in the queue
            while(inputMessageQueue->try_receive(buffer, queueMaximumMessageSize, receivedSize, priority))
                BaseMessage * msg = reinterpret_cast<BaseMessage*>(buffer);
            // Give other threads a chance to run
            // This is also an interruption point
            boost::this_thread::sleep(boost::posix_time::millisec(50)); <==Here
    catch(boost::thread_interrupted const&)


John Davies
Home Respiratory Care
Philips Home Healthcare Solutions
1740 Golden Mile Highway
Monroeville, PA 15146

Email: john.davies_at_[hidden]
Fax: 724-387-4109

The information contained in this message may be confidential and legally protected under applicable law. The message is intended solely for the addressee(s). If you are not the intended recipient, you are hereby notified that any use, forwarding, dissemination, or reproduction of this message is strictly prohibited and may be unlawful. If you are not the intended recipient, please contact the sender by return e-mail and destroy all copies of the original message.

Boost-users list run by williamkempf at, kalb at, bjorn.karlsson at, gregod at, wekempf at