Skip to Main Content

Java Programming

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Timer timeout to kill method call

807588Jul 18 2008 — edited Mar 6 2009
Hi,



This seems trivial yet has not proved to be so. Since I want fresh ideas I will not post my approach yet I would like to simply present my problem and see if someone can think of a simple solution to it.



I am not looking for a syntax solution from someone. Just approach ideas.



Problem is like this. I have a method call. (It is a "receive" function that is supposed to return a File. There are many different ways in which it does this (which we don't care about these) besides the fact that some of these methods are not reliable and cause the code to hang. The desired result is to wrap receive with some sort of timer. If the timer does not timeout before receive returns a File I want the File to be usable in the rest of the code. If the timer does timeout I want to throw an exception that I can catch later on in the code.



So if you have a second and can help out I would appreciate that. If the responses prove to be the same as my current 'solution' then I will paste my code and ask for more help from the community.



Thanks

M@
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Apr 3 2009
Added on Jul 18 2008
15 comments
855 views