Subj : Re: [RFC] Boost.Threads on its way to C++0x To : comp.programming.threads From : Howard Hinnant Date : Fri Apr 29 2005 09:41 pm In article , Ben Hutchings wrote: > Peter Dimov wrote: > > Ben Hutchings wrote: > >> > >> The two thread constructors are a crime against type-safety. Thread > >> starter/joiners and identifiers should be separate types. > > > > Why should starters/joiners be types? Why not functions returning/taking an > > id? > > I wouldn't argue that starting and joining need to be combined in a > single class. However thread joinability is a resource which had > better not be leaked. Some kind of resource management is needed and > the non-default constructor of boost::thread provides RAII. The boost::thread dtor takes this into account. If the local boost::thread object destructs before an explicit join, the dtor detaches the referenced thread. I.e. the boost::thread model assumes that the programmer will sometimes not want to join with the thread, allows for it, and makes sure no damage is done. -Howard .