Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Please Help Regarding Time OUT  RSS feed

 
Sanjeev Sharma
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi
I'm using struts, i call a method from ACTION class and i would like to exit that method in case the method takes more than 15 seconds.
Please help me with some sample code.

Thanks in advance
Sanjiv
 
Stan James
(instanceof Sidekick)
Ranch Hand
Posts: 8791
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, welcome to the ranch!

Here's a trick I've used:

Note that if the other thread is not done yet, I just stop waiting. It still runs to completion, but nobody is interested in the result any more. You can interrupt it which may or may not make it stop what it's doing.

In Java 5 and later, see Future which does roughly the same thing in a much neater way.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!