
Anyone have any insight as to why these threads are not being terminated? I have been doing a lot of different tests to determine where it might be going wrong. And thus far, I have not been able to find exactly where or why the threads will not join properly. Here is my my recent code. int sayHello(int x){ cout << "Hello world from thread: " << x << endl; } int main(int argc, char *argv[]) { InitConfig mconfig; if(mconfig.setConfig()){ boost::thread_group Tg; // int pid; // // if(fork()) return 0; // // chdir("/"); // setsid(); // umask(0); // // pid = fork(); // // if(pid){ // printf("Daemon Started: %d\n", pid); // return 0; // } //while(1){ //if(Tg.size() == 0){ cout << "Thread Size Before: " << Tg.size() << endl; for(int i = 1; i < 25; i++){ dmParse parse; //Tg.create_thread(boost::bind(&dmParse::onInit,parse,i)); Tg.create_thread(boost::bind(sayHello,i)); } cout << "Thread Size: " << Tg.size() << endl; Tg.join_all(); Tg.interrupt_all(); cout << "Thread Count After:" << Tg.size() << endl; //}else{ //cout << "Threads Running, taking a nap. Thread Count: " << Tg.size() << endl; //sleep(60); //} //} } } On Tue, Apr 7, 2009 at 11:54 AM, Scott McMurray <me22.ca+boost@gmail.com>wrote:
On Tue, Apr 7, 2009 at 14:45, Jeremy Rottman <rottmanj@hsmove.com> wrote:
Currently this is what I am testing with, when all threads are finish running, I then join all the threads to terminate them. Doing so should
give
me a thread group size of 0. However, this is now the case. Currently after I join the threads, the thread group size is still 0 [sic? 24, probably].
Given that create_thread returns a pointer to the new thread, it makes since that join_all wouldn't remove the threads, since then the pointer would dangle.
I don't know the best way to do what you want, though. _______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users