Subj : Re: Killing threads To : comp.programming.threads From : David Hopwood Date : Wed Aug 17 2005 02:15 am David Schwartz wrote: > "Srini Palthepu" wrote: >>I am trying to kill the hung thread and respawn a new one as a way >>of cleaning up. > > No good. What if it holds a mutex? You have to fix the problem. > >>I am using ACE toolkit thread framework that essentially >>will be translated to Solaris thread sys calls at lowlevel. > > How could a thread get hung? What can go wrong? There are any number of blocking system functions that can get hung for any number of reasons (because the POSIX API has not been systematically designed to allow all functionality to be accessed by calls that are non-blocking or support timeouts). So it isn't in general possible to avoid the possibility of a thread becoming hung -- but it is possible to avoid holding locks when calling functions that might hang, so that cancellation can be made reliable. > If you really need failure recovery, you need to use processes, not > threads. With processes, you can precisely control how they interact > and recover from a failure, but not with threads. That's impractical in many cases. -- David Hopwood .