
From: boost-users-bounces@lists.boost.org [mailto:boost-users-bounces@lists.boost.org] On Behalf Of boostguy@kapiladhanvi.com
<snip>
--- MyThread.h ---- typedef boost::shared_ptr<Runnable> myPtr;
class MyThread { public: MyThread( ); ~MyThread( ); private: myPtr p1; } --- MyThread.cpp ---- MyThread::MyThread( ) : p1( new Runnable() ) { cout << "MyThread::MyThread( ) constructor " << endl; boost::thread th( boost::bind( &Runnable::run, p1) ); } ---- Runnable.cpp --- // this is the only function in Runnable.h void Runnable::run() { cout << "Runnable::run() YUPPIE! "<< endl; } ------ end ----------- The code compiles, but nothing happens.. I am missing something here ?? Is there something else I need to do to start my thread??
How are you preventing your program from ending before the thread finishes (or even starts up)? In other words, what do you do after you create an instance of MyThread? Do you wait for some time? -delfin