This week's book giveaway is in the Jython/Python forum.
We're giving away four copies of Murach's Python Programming and have Michael Urban and Joel Murach on-line!
See this thread for details.
Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

TimerTask delay shorter than the time it task to execute the run() method  RSS feed

 
Andrei Antonescu
Ranch Hand
Posts: 75
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello all,

I am having a timertask set to be executed at every 1 second.
The task it's programmed to do smth that could sometimes take longer than 1 second.
Will a second call to run() start even if the first hasn't finished executing run() (in case the 1 second delay has elapsed)?

Thanks in advance
 
Stephan van Hulst
Saloon Keeper
Posts: 6979
110
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you are executing using a Timer, then the first task will complete, and only then will the second one be started. If your tasks take longer than the delay between tasks, then either the next task will start immediately, or it will simply wait for the delay, depending on whether you used schedule() or scheduleAtFixedRate().

Regardless, your task should not take this long. Timer expects short tasks that execute quickly.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!