• 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
  • Tim Cooke
  • paul wheaton
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
  • Paul Clapham
  • Liutauras Vilda
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

Scheduling task execution in defined intervalls

 
Ranch Hand
Posts: 62
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

I would like to schedule task execution in bit complicated way.

I want to split a day into intervals, and define the periods of the task execution within these time intervalls.

For example:

8:00am to 13:00pm = 5000 (milliseconds)
13:00pm to 21:00pm = 3000

So, between the first period i want periodic task execution in 5 seconds, and for the latter 3 seconds.

Are there some scheduling framework which supports this, or shall i implement it with Timer?
If only the latter is possible any hint would be nice.

Thanks
 
Bartender
Posts: 1210
25
Android Python PHP C++ Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Check if Quartz scheduler framework's cron-like trigger expressions do what you want - see the examples at the bottom of the page. 2 expressions - one for 5 second tasks and one for 3 second tasks - will probably be enough.
 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Try if This might help. This is using Timer and TimerTask. Currently i'm using threads for tasks.
You can change accordingly.

 
Ranch Hand
Posts: 174
Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You can also look at ScheduledExecutorService class.
 
Ranch Hand
Posts: 78
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Quartz is always a better option.you will have lot of options to scedule a job.
 
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Quartz is always a better option.you will have lot of options to scedule a job.


I disagree. Just because it has more options does not mean it is the better choice for all situations. It also has higher overhead for settings things up, making its use questionable if the extra options aren't needed.
 
Ramesh Sunkara
Ranch Hand
Posts: 78
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ya I do accept. I should have not used the word "always"
 
This. Exactly this. This is what my therapist has been talking about. And now with a tiny ad:
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic