File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Threads and Synchronization and the fly likes Scheduling task execution in defined intervalls Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Threads and Synchronization
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: 61
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: 529
    
    6
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: 42594
    
  65
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.


Ping & DNS - my free Android networking tools app
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://aspose.com/file-tools
 
subject: Scheduling task execution in defined intervalls