The simplified version of my code looks as follows:
class threadCreator
{
void threadFunction(void){
// use some private data members and do something.
}
void createThread(void){
boost::thread myThread(
boost::bind(&threadCreator::threadFunction,this));
myThread.detach();
}
}
This program waits for the thread to complete execution and then exits, even though I call a detach method on the thread. If I remove the class, and create my thread just in a function, this seems to work as expected.
I think it has something to do with the object still being in memory. However I am C++ learner and not sure on how to resolve this.