Boost logo

Boost :

From: Greg Colvin (gcolvin_at_[hidden])
Date: 2001-06-27 12:13:45


From: John Max Skaller <skaller_at_[hidden]>
> Greg Colvin wrote:
>
> > Because killing threads is a bad idea.
>
> No, it isn't a 'bad idea'. It is essential
> in many applications, in particular, it is essential
> in most multithreaded servers to kill client connection
> management threads when they're unable to detect that
> the connection is lost or exceeded some bound
> (such as 'out of money').
>
> A thread blocked waiting for input
> cannot always detect such conditions (only an actual
> input error). In such cases, cancellation is not
> a bad idea, it is mandatory.

To be clear, just stopping a thread "out of nowhere" is
a bad idea, as there is then no way to get out of any
monitors it has entered. Better is a way to throw an
exception on the thread, so as to let destructors run.

Sometimes it is even better to spawn processes instead
of threads, so the OS can take care of cleaning up a
killed process.


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk