Thanks, It worked.
regards,
Lloyd
Lloyd wrote:The thread pointer (th) will be destroyed once it goes out of scope, right after end-curly-bracket in the loop.
> boost::thread_group tg;
> for(int i=0;i<n;++i)
> {
> boost::shared_ptr<boost::thread> th(new boost::thread(boost::bind(&Enum::Execute,shared_from_this(),i,x)));
> tg.add_thread(th.get());
> }
> tg.join_all();
>
> But the threads are not joined, it is exiting without completion. What could be the mistake I am doing?
I think this is what you are looking for:
tg.create_thread(boost::bind(&Enum::Execute,shared_from_this(),i,x));
boost::thread_group tg;
for(int i=0;i<n;++i)
{
}
tg.join_all();
--
Best regards,
Martin Dyring-Andersen
_______________________________________________
Boost-users mailing list
Boost-users@lists.boost.org
http://lists.boost.org/mailman/listinfo.cgi/boost-users