Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Thread for a given time window

 
hansi flick
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • 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
 
Henry Wong
author
Marshal
Pie
Posts: 21220
81
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • 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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic