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

TimeOutException  RSS feed

 
Poornima Sharma
Ranch Hand
Posts: 114
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How can we create a time out exception for a particular method after a stipulated amount of time?
 
Deepak Chopra
Ranch Hand
Posts: 433
Eclipse IDE Firefox Browser Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
May be you can try something like this -

--> Write a class that extends TimesTask

Lets say ClassA extends TimerTask..

in your main class do something like this-

Time timer = new Timer( );

timer.schedule(new ClassA(), timeOutTime) ;

If something happens before timeout - you can cancel the timer by timer.cancel( )
otherwise let the timer run and find someway to throw an exception from classA...

cheers...

 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!