• 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

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

 
Ranch Hand
Posts: 75
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Saloon Keeper
Posts: 15510
363
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
reply
    Bookmark Topic Watch Topic
  • New Topic