Re: Yet again - closing a thread
- From: Joseph M. Newcomer <newcomer@xxxxxxxxxxxx>
- Date: Fri, 03 Feb 2006 12:03:03 -0500
The question is first, do you know that the wait succeeds? If it doesn't succeed, you
have to deal with the problem. However, saying that it is not necessary to test
conditions because erroneous conditions can't be handled isn't a good answer. If you
handle the conditions, you are forced to think about what proper recovery is and how to
deal with it, even if "proper recovery" is "terminate app", which is usually a very bad
idea indeed. However, the code shown has the characteristic that instead of reporting an
internal error and taking some form of graceful recovery, if there IS an error, the
appliction just hangs. That's far less acceptable. The "ostrich approach" to errors
doesn't work.
If the wait call fails, you have a problem. You have to figure out how to deal with that
problem in the context of your application, because if it fails, it should represent a
deep error. But ignoring the failure and locking up the application is not even close to
acceptable.
It is probably a bug if the wait fails, but it is best to catch and analyze the bug at
design time, should it happen. Hence the ASSERT statements which will cause a meaningful
error at development time, which allows you to identify why there is a bug.
Error recovery is not always easy. Failure to recover is untenable. (I once spent an
entire year taking a "working" program and making sure that it could run 24/7, literally.
A bug that would happen once every 10,000 times an operation was done would happen a
couple times an hour. I took it from MTBF of 45 minutes to an MTBF that was at least six
weeks--that's how long we ran before building power failed in a major power outage. All
the work was in error detection and recovery, and the program more than tripled in size.
So you have to figure out how to recover; that is part of the problem description.)
joe
On Fri, 3 Feb 2006 03:26:12 -0800, "dududuil" <dududuil@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote:
Thanks all, I'd made some serious advance sicnce, and true - the main problemJoseph M. Newcomer [MVP]
was some windowing stuff, the working thread had done.
One more question is this: asuming that my thread does simple tasks, and
terminate itself very quickly: If the Wait call fails (WHY?) I can not
continue - and have no solution but to termininate everything all together -
which is unacceptable.
Does anyone has an idea of what to do after the Wait call fails, and still
you must be certain that the thread had terminated itself?
Thanks
Dudu
email: newcomer@xxxxxxxxxxxx
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm
.
- References:
- Re: Yet again - closing a thread
- From: Joseph M . Newcomer
- Re: Yet again - closing a thread
- Prev by Date: Re: heeeeeeeeeeeeeeeellllllllllllllppppppppppppppppppppp
- Next by Date: Re: Yet again - closing a thread
- Previous by thread: Re: Yet again - closing a thread
- Next by thread: Re: Yet again - closing a thread
- Index(es):
Relevant Pages
|