How do i implement a scheduler in java for many tasks(>1000) ?

N

neo

Hi ,
I am trying to write a scheduler in java for a huge number of tasks.
The Timer class says it does not like big resouce intensive tasks as
it would load its thread and lead to bunching of the later scheduled
ones.

Which is the best way to implement this scheduler in java and keep it
very accurate and scalable ????
 
R

Roedy Green

Which is the best way to implement this scheduler in java and keep it
very accurate and scalable ????

you could use the Timer, but when the task was something nasty, spawn
a yet another thread.
 
B

bm

Scheduled tasks are simply future events with time stamps
e1, e2, .., en where this list of time stamps are partially ordered,
that is e1 <= e2 <= .. <= en.

So you can create a Vector of these events and have only
one Timer. When the Timer goes off all events with that
time stamp in the queue are fired.

You may think if say there are n events with the same time stamp
there would be some time difference, say few mili-seconds perhaps,
between firing the event 1 and event n. But the same would be true
with n Timers. As timers are fired in sequence by the OS not all at
once.
 
A

A Dahlman

neo said:
Hi ,
I am trying to write a scheduler in java for a huge number of tasks.
The Timer class says it does not like big resouce intensive tasks as
it would load its thread and lead to bunching of the later scheduled
ones.

Which is the best way to implement this scheduler in java and keep it
very accurate and scalable ????

Nice to hear from you, Neo...

If by "scheduler" you mean to start some tasks at time A, others at time B,
and so forth, you have the answer from Roedy and "bm".

OTOH if you need some tasks to wait for others to complete--however long it
may take--then take a look at:

http://pws.prserv.net/ad/programs/Programs.html#TaskScheduler

It shows how to assign each task to a thread and define "rules" for when each
task may start. Yes, could use lots of memory, but maybe less than you
expect. However, it does appear to be fully scalable.

Hope this helps. Tony Dahlman
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,756
Messages
2,569,540
Members
45,025
Latest member
KetoRushACVFitness

Latest Threads

Top