Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / August 2007

Tip: Looking for answers? Try searching our database.

Timing an Action

Thread view: 
Hal Vaughan - 06 Aug 2007 20:03 GMT
I have a program that communicates with another program on the same
computer.  Sometimes the other program freezes.  When that happens, I can
call that program and nothing happens and I don't get any signal that
things are frozen.

I was thinking of using another thread and timing the action.  I could set a
time, like 10 seconds and if the main thread hasn't reported in, then I
could kill and restart the other program and re-initialize things on my
end.

I know I could use a thread and just have it sleep for the time I want to
wait, but is there a better way to do this?  I know there are tons of
things in the API I've never heard of.  Is there anything for checking when
a thread has been on the same instruction for too long or to check and find
out if a thread is waiting for another program to get back to it or
anything like that?

Any ideas or functions or classes that might help with this are appreciated!

Thanks!

Hal
Roedy Green - 06 Aug 2007 22:53 GMT
>I was thinking of using another thread and timing the action.  I could set a
>time, like 10 seconds and if the main thread hasn't reported in, then I
>could kill and restart the other program and re-initialize things on my
>end.
see http://mindprod.com/jgloss/timer.html
Signature

Roedy Green Canadian Mind Products
The Java Glossary
http://mindprod.com

Hal Vaughan - 07 Aug 2007 09:07 GMT
>>I was thinking of using another thread and timing the action.  I could set
>>a time, like 10 seconds and if the main thread hasn't reported in, then I
>>could kill and restart the other program and re-initialize things on my
>>end.
> see http://mindprod.com/jgloss/timer.html

My mistake was searching your glossary with "time" and "timing" instead of
timer, which, when you think about it, was short sighted on my part.

Thanks!

Hal
Roedy Green - 07 Aug 2007 21:00 GMT
On Tue, 07 Aug 2007 04:07:43 -0400, Hal Vaughan
<hal@thresholddigital.com> wrote, quoted or indirectly quoted someone
who said :

>My mistake was searching your glossary with "time" and "timing" instead of
>timer, which, when you think about it, was short sighted on my part.

If you look at the bottom of the page
http://mindprod.com/jgloss/time.html, you will have seen a link to
Timer.  Often if the page does not contain what you want, the links
section will take you there.
Signature

Roedy Green Canadian Mind Products
The Java Glossary
http://mindprod.com

tzvika.barenholz@gmail.com - 07 Aug 2007 07:22 GMT
> I have a program that communicates with another program on the same
> computer.  Sometimes the other program freezes.  When that happens, I can
[quoted text clipped - 18 lines]
>
> Hal

use a Scheduled Execution Service (http://java.sun.com/j2se/1.5.0/docs/
api/java/util/concurrent/ScheduledExecutorService.html) to schedule
your killer thread after your desired delay.

another option is to schedule the job at hand (i.e. that which
sometimes gets stuck) with a specified timeout, and let the threads
required for the job run on their own:
ExecutorService.awaitTermination() - but it blocks.

T
Hal Vaughan - 07 Aug 2007 09:05 GMT
>> I have a program that communicates with another program on the same
>> computer.  Sometimes the other program freezes.  When that happens, I can
[quoted text clipped - 30 lines]
>
> T

On this project I'm trying to stick with Java 2 (I'm working with some
people that tend to be VERY slow in updating their computers!).  I will
file that, though because it will come in handy when I can work with later
versions.

Thanks!

Hal


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.