|
Boost Users : |
Subject: Re: [Boost-users] Problem with boost:thread
From: Daniel Veneros (dann.vd_at_[hidden])
Date: 2010-03-04 12:13:10
Thanks!
But I said that the thread wont start because in other class I defined, that
inherits from this "Thread" class.
I implemented the abstract run() method so it just prints a line to the
output:
class Trash : public Thread {
std::string garbage;
public :
Trash(std::string newString){garbage = newString;};
void run(){ std::cout << "RUNNING" << std::endl;};
}
int main(int argc, char** argv) {
Trash myTrash("hello");
myTrash.start();
}
and whenever I run the project (using boost::thread or using
boost::thread_group with the correction you provided) it wont show the
output... "RUNNING".
BUT, if I add m_Thread.join(); it shows that output.
Any idea why?
Thanks!!
On Thu, Mar 4, 2010 at 1:02 PM, Igor R <boost.lists_at_[hidden]> wrote:
> > void start(){m_Thread = new boost::thread( &Thread::run, this ); };
> > //wont start unless I add m_Thread.join();
>
> The thread is created and started anyway. Join() just tells the
> *caller* thread to wait until m_Thread finishes.
>
>
> > void start(){g_Thread.create_thread(&Thread::run); };
>
> g_Thread.create_thread(boost::bind(&Thread::run, this));
> _______________________________________________
> Boost-users mailing list
> Boost-users_at_[hidden]
> http://lists.boost.org/mailman/listinfo.cgi/boost-users
>
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