Solved

crashed threads

Posted on 1998-11-09
5
163 Views
Last Modified: 2010-04-04
how can I tell if a thread has crashed?

if Im running an additional thread, is there an easy way to tell if the thread has crashed?

for that matter, what actually happens when a thread crashes?  in my App, the other threads seem to carry on and not notice that the thread is dead, except when some task that the thread was supposed to perform doesnt happen.
if this thread crashes, somehow the other threads need to know, and shut themselves down gracefully.

thanks

Ben

0
Comment
Question by:1750
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
5 Comments
 
LVL 12

Accepted Solution

by:
rwilson032697 earned 50 total points
ID: 1346351
Bascially there isn't at least in a passive way. It is equivalent to telling if your application has crashed.

One approach that you can use is to require all threads to periodically update status information in some central location. Failure to do so within a certain length of time implies that the thread may have crashed.

There is no real fool-proof way other than to be very careful how you write the code and use exception handling to catch problems and exit or otherwise deal with them gracefully.

Cheers,

Raymond.

0
 

Author Comment

by:1750
ID: 1346352
would putting a try..finally inside the execute method work?  ie:

procedure TMyThread.Execute;
begin
  try
    .
    .
  finally
    if not terminated then IveCrashed:=True;
  end;
end;

or would I need to use try..except?  Ive never quite understood the difference between the two.  




0
 

Author Comment

by:1750
ID: 1346353
oops!  if forgot to include:

Brain.Engage;

I do know the difference between try..finally and try..except!

ive tried the try..finally scenario, and it doesnt seem to work.

any ideas?


0
 
LVL 12

Expert Comment

by:rwilson032697
ID: 1346354
The try except scenario should work if the crash is hapenning due to an exception. However, it may just be getting into an inifinite loop, or is blocked waiting access to a semaphore or mutex which it is never granted etc..

The actual crash might be happening the the synchronise method in which case it is occurring in the main VCL thread (which might explain whay a try..finally doesn't seem to work...). Though I would have thought this would still generate an exception (which it might but is being caught and ignored...)

Raymond.

0
 

Author Comment

by:1750
ID: 1346355
thanks
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
Attackers love to prey on accounts that have privileges. Reducing privileged accounts and protecting privileged accounts therefore is paramount. Users, groups, and service accounts need to be protected to help protect the entire Active Directory …
Finding and deleting duplicate (picture) files can be a time consuming task. My wife and I, our three kids and their families all share one dilemma: Managing our pictures. Between desktops, laptops, phones, tablets, and cameras; over the last decade…

710 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question