| Author |
How to time out :confused:
|
Srini Kesavan
Greenhorn
Joined: Jan 18, 2003
Posts: 18
|
|
I would like to exit out of the program if a method call is taking too much time to process. How can I do that? Example:- IData outputDocument = invoke(context, inputDocument); if the invoke is taking more than 10 secs. I would like to exit out of the program. Any help will be useful. Thanks in advance
|
SCDJWS,SCWCD,SCJP
|
 |
Ernest Friedman-Hill
author and iconoclast
Marshal
Joined: Jul 08, 2003
Posts: 24051
|
|
Immediately before calling the long-running method, start a new Thread running which sleeps for the longest possible time, then exits the program. When the method completes, stop the thread. If t.interrupt() is called within 10 seconds, the app will continue; otherwise it will exit.
|
[Jess in Action][AskingGoodQuestions]
|
 |
Srini Kesavan
Greenhorn
Joined: Jan 18, 2003
Posts: 18
|
|
|
Thanks for your help. Really appreciate it.
|
 |
Gaurav Mac Mathur
Ranch Hand
Joined: Feb 19, 2002
Posts: 47
|
|
I agree this possibally teh best possible solution, but let me warn you that the Sleep time may not be what you prescribe in the code, As thread prioriy are JVM implementation dependent. _based on my Theoratical Knowledge_ Cheers
|
 |
 |
|
|
subject: How to time out :confused:
|
|
|