This week's book giveaway is in the General Computing forum.
We're giving away four copies of Arduino in Action and have Martin Evans, Joshua Noble, and Jordan Hochenbaum on-line!
See this thread for details.
The moose likes Threads and Synchronization and the fly likes Scheduling task execution in defined intervalls Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


JavaRanch » Java Forums » Java » Threads and Synchronization
Reply Bookmark "Scheduling task execution in defined intervalls" Watch "Scheduling task execution in defined intervalls" New topic
Author

Scheduling task execution in defined intervalls

Gabriel Beres
Ranch Hand

Joined: Sep 09, 2006
Posts: 55
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
Karthik Shiraly
Ranch Hand

Joined: Apr 04, 2009
Posts: 369
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.
Vineeth Arvind
Greenhorn

Joined: Jun 07, 2011
Posts: 1
Try if This might help. This is using Timer and TimerTask. Currently i'm using threads for tasks.
You can change accordingly.

Chinna Eranna
Ranch Hand

Joined: Dec 08, 2009
Posts: 174

You can also look at ScheduledExecutorService class.


- Chinna
Ramesh Sunkara
Ranch Hand

Joined: Mar 01, 2010
Posts: 78
Quartz is always a better option.you will have lot of options to scedule a job.
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 35443
    
    9
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.


Android appsImageJ pluginsJava web charts
Ramesh Sunkara
Ranch Hand

Joined: Mar 01, 2010
Posts: 78
Ya I do accept. I should have not used the word "always"
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: Scheduling task execution in defined intervalls
 
Similar Threads
Thread-based timer versus Timer Class-based timer
Can timer Update swing Widgets , or some tips needed.
Re-scheduling a Task - HOW?
How do I convert this to a program. thanks.
How to i invoke a method every 24 hours