Help coderanch get a
new server
by contributing to the fundraiser
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Devaka Cooray
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Tim Moores
  • Carey Brown
  • Mikalai Zaikin
Bartenders:
  • Lou Hamers
  • Piet Souris
  • Frits Walraven

SET TIME OUT with TIMER

 
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
can i please get an example, codes to enable setTimeout in a timer. Thanks in advance. Its vvvv urgent. Please help me
 
author
Posts: 23956
142
jQuery Eclipse IDE Firefox Browser VI Editor C++ Chrome Java Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Zaafir Barahim:
can i please get an example, codes to enable setTimeout in a timer. Thanks in advance. Its vvvv urgent. Please help me



Neither the java.util.Timer or the javax.swing.Timer class has a timeout feature. Hence, no setTimeout() method, and no enable of that feature.


Now... By timeout I am assuming that you mean some sort of results return when the task is not completed within a certain amount of time. Unfortunately, you will have to implement this yourself.

Have your long running task periodically check a certain flag, say some sort of abort flag. If the abort flag is set, then it will have to exit cleanly. You will then need another timer task which will set this abort flag, and report that the timeout occurred.

And BTW, this timeout task can't use the same java.util.Timer -- so create another one. You shouldn't be executing long running tasks in a javax.swing.Timer, so I will assume you mean java.util.Timer.

Henry
[ February 19, 2007: Message edited by: Henry Wong ]
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic