kaliwanagan wrote:
I was just curious as to why the class destructor are (apparently) being called multiple times. >
[...]
I would appreciate if someone can enlighten me on this. Will having the destructor called multiple times be a cause of concern? Will it cause some undefined symptoms? Is there a way to completely avoid this situation?
The multiple callings on destructor are not on same object. If you add a copy constructor, TestingClass(const TestingClass &) { std::cout << "constructor called" << std::endl; } you will see the constructor being called same times. You can use Boost.Bind to avoid multiple object-copying. struct TestingClass { ... void run() { std::cout << "run() called" << std::endl; } ... } ... void testBoostThread() { boost::thread thrd(boost::bind(&TestingClass::run, &testclass)); thrd.join(); }