Boost logo

Boost Users :

From: Prashant Thakre (prashant.thakre_at_[hidden])
Date: 2006-10-12 04:12:38


Peter Dimov <pdimov <at> mmltd.net> writes:
>
> That said, why do you even have to keep the boost::thread objects? There
> aren't many useful things that you could do with a boost::thread; if you run
> 24/7 you should be able to just spawn the threads "detached":
>
> boost::thread( f );
>
> without keeping them in a thread group.
>
Hi,
 On Windows the ~thread() doesnot detach the thread. Hence, the below listed
code will throw boost::thread_resource_error().

 int num_threads = 0;
 while(true)
  {
   try
   {
    boost::thread thr(f);
    ++num_threads;
   }
   catch (const std::exception & e)
   {
     std::cout<<"Exception..."<<e.what()<<std::endl;
     std::cout<<"Number of threads created... "<<num_threads<<std::endl;
     break;
   }
  } // end of while

 Would it be possible to create threads in detached state with boost_1.34 ?

--
regards,
Prashant

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