Hi everyone, I am trying to use the boost multithreading library. I am having a problem as the join() function for the thread never returns. I am using a boolean variable to indicate when the thread should stop running. Here is basically a stub of what I am doing: //........................................ bool m_RunThread = false; scoped_ptr myThread; //....................................... void MyObject::StartThread() { m_RunThread = true; myThread.reset(new boost::thread(boost::bind (&MyObject::MyThreadFunc, this))); } void MyObject::StopThread() { m_RunThread = false; myThread.join(); // this function never returns! ... Never gets here.... } void MyObject::MyThreadFunc() { while (m_RunThread) { // do something } } However, the join() function in StopThread never returns. I think that using a variable to synchronize this is probably not a good idea. Any thoughts and suggestions? Cheers, K
participants (1)
-
xargon