Boost logo

Boost :

From: williamkempf_at_[hidden]
Date: 2001-06-29 08:31:42

--- In boost_at_y..., "Peter Dimov" <pdimov_at_m...> wrote:
> From: <williamkempf_at_h...>
> > --- In boost_at_y..., "Greg Colvin" <gcolvin_at_u...> wrote:
> > > I prefer detach, so that an explicit detach() function is
> > > not needed. It's easy enough to join() when appropriate.
> > > But then I've yet to write an application that needed to
> > > join.
> >
> > Our experiences differ. I very rarely have need for a detached
> > thread.
> My limited experience with threads has always followed the
pattern "spawn a
> worker thread to perform lengthy operation X without blocking the
> thread, leaving it responsive." (Minor variations include "to
> background operation Y", like keeping a buffer full of data.)
> What is the usual 'join' model?

You didn't go far enough with this description to illustrate the
differences between joined and detached threads. This description
applies no matter which pattern is used. The difference is that a
detached thread does not need to run to completion (in fact they are
usually coded with infinite loops) while a joined thread does.

(BTW, the pthreads standard correctly points out that join() is a
convenience... detached threads can be "waited on" through a
condition variable. However, the distinction I made above
illustrates the proper difference between the two patterns, if not
the exact meaning in Posix.)

Bill Kempf

Boost list run by bdawes at, gregod at, cpdaniel at, john at