Celebrate National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

crashed threads

Posted on 1998-11-09
5
Medium Priority
?
167 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 150 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

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

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

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
Suggested Courses

730 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