Boost logo

Boost Users :

From: Delfin Rojas (drojas_at_[hidden])
Date: 2006-02-09 22:59:12


> From: boost-users-bounces_at_[hidden]
> [mailto:boost-users-bounces_at_[hidden]] On Behalf Of
> boostguy_at_[hidden]
>
> <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


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net