• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Thread for a given time window

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'd like to run a Listener in a Thread from a certain point of time on for a certain amount of time (some hours).
I found Timer and TimerTask classes, however JavaDoc tells me that TimerTasks should complete quickly, which is not the case for my Thread. Is there a better and easy possibility to achieve the task?
Thanks
 
author
Posts: 23951
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

hansi flick wrote:I found Timer and TimerTask classes, however JavaDoc tells me that TimerTasks should complete quickly, which is not the case for my Thread. Is there a better and easy possibility to achieve the task?
Thanks



TimerTasks should complete quickly because there is only one thread that is dedicated to the tasks -- having a long running task can starve the other tasks.

If you only have a single task in the timer, then it shouldn't be a problem.

Henry
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic