27 Jan
2008
27 Jan
'08
12:50 a.m.
On Sun, 27 Jan 2008 10:54:27 +1100, anthony kelly wrote:
The only examples I can find show starting the thread at the same time it is defined! Is it possible to define the thread as a class member, and start it later? If so, what would the syntax for this line be? If not, can you suggest an alternative structure?
Hi, That is the only way I've used it but you can always use a shared_ptr to the thread: class C {... private: ... boost::shared_ptrboost::thread thread; }; void C::Start() { running=true; thread.reset(new thread(&C::ThreadJob)); } Only thing you'd have to be careful of is copying of class C but you can inherit from boost::noncopyable to avoid any issues. -- Sohail Somani http://uint32t.blogspot.com