Boost Thread Hanging on _endthreadex

Posted by FranticPedantic on Stack Overflow See other posts from Stack Overflow or by FranticPedantic
Published on 2010-04-08T21:28:20Z Indexed on 2010/04/08 21:33 UTC
Read the original article Hit count: 524

Filed under:
|
|

I think I am making a simple mistake, but since I noticed there are many boost experts here, I thought I would ask for help.

I am trying to use boost threads(1_40) on windows xp. The main program loads a dll, starts the thread like so (note this is not in a class, the static does not mean static to a class but private to the file).

static boost::thread network_thread;

network_start()
{
  // do network stuff until quit is signaled
}

DllClass::InitInstance() 
{
network_thread = boost::thread(boost::bind<void>(network_start));
}

DllClass::ExitInstance()
{
  //signal quit (which works)
   //the following code is slightly verbose because I'm trying to figure out what's wrong
    try {
       if (network_thread.joinable() ) {
       network_thread.join();
  } else {
   TRACE("Too late!");
  }
 } catch (boost::thread_interrupted&) {
  TRACE("NET INTERRUPTED");
 }
}

The problem is that the main thread is hanging on the join, and the network thread is hanging at the end of _endthreadex. What am I misunderstanding?

© Stack Overflow or respective owner

Related posts about c++

Related posts about boost