AppletTalk.com Forum Index AppletTalk.com
Java discussions newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

task sheduling

 
Post new topic   Reply to topic    AppletTalk.com Forum Index -> Java Help
View previous topic :: View next topic  
Author Message
Maxim Kasimov
Guest





PostPosted: Wed Feb 23, 2005 11:42 am    Post subject: task sheduling Reply with quote




i need to shedule some task at the determined time.
in api reference there is Timer class ( and TimerTask ),
but "This class does not offer real-time guarantees: it schedules tasks using the Object.wait(long) method."

in my midlet, it is critical to shedule tasks at the certain time.

i think i should use System.currentTimeMillis(), and in run() check is the time to shedule task.

is there some elegant way to shedule tasks with real-time guarantees?

--
Best regards,
Maxim Kasimov
Back to top
Paul van Rossem
Guest





PostPosted: Wed Feb 23, 2005 1:42 pm    Post subject: Re: task sheduling Reply with quote



It depends on your requirements.

1) If it is critical that your task starts with millisecond accuracy,
then for starters, you should not use a PC. Windows simply can't handle
this. And you should not be using Java. Java starts several threads that
compete for CPU-time. One of these is the garbage collector, that may
take a few millis or more, possibly just when your real-time task is due.

2) If your requirements are less critical, then by all means use Java.
In that case just compute the time to sleep (subtract the current time
from the planned activation time), and start a timer.
If your requirement is about seconds accuracy, and you are not running
any other programs, this should generally do the job.

3) Busy waiting is the worst option, it degrades system performance
quite heavily and, as you already found out, doesn't guarantee a thing.

Paul.

On 23-02-2005 12:42, Maxim Kasimov wrote:
Quote:

i need to shedule some task at the determined time.
in api reference there is Timer class ( and TimerTask ),
but "This class does not offer real-time guarantees: it schedules tasks
using the Object.wait(long) method."

in my midlet, it is critical to shedule tasks at the certain time.

i think i should use System.currentTimeMillis(), and in run() check is
the time to shedule task.

is there some elegant way to shedule tasks with real-time guarantees?


Back to top
Maxim Kasimov
Guest





PostPosted: Wed Feb 23, 2005 2:16 pm    Post subject: Re: task sheduling Reply with quote




Paul van Rossem wrote:
Quote:
It depends on your requirements.

1) If it is critical that your task starts with millisecond accuracy,
then for starters, you should not use a PC. Windows simply can't handle
this. And you should not be using Java. Java starts several threads that
compete for CPU-time. One of these is the garbage collector, that may
take a few millis or more, possibly just when your real-time task is due.
it is a midlet about - j2me application

time between screen repaints varies about 70 to nearly 500 milliseconds


Quote:

2) If your requirements are less critical, then by all means use Java.
In that case just compute the time to sleep (subtract the current time
from the planned activation time), and start a timer.
If your requirement is about seconds accuracy, and you are not running
any other programs, this should generally do the job.

3) Busy waiting is the worst option, it degrades system performance
quite heavily and, as you already found out, doesn't guarantee a thing.

Paul.

On 23-02-2005 12:42, Maxim Kasimov wrote:


i need to shedule some task at the determined time.
in api reference there is Timer class ( and TimerTask ),
but "This class does not offer real-time guarantees: it schedules
tasks using the Object.wait(long) method."

in my midlet, it is critical to shedule tasks at the certain time.

i think i should use System.currentTimeMillis(), and in run() check is
the time to shedule task.

is there some elegant way to shedule tasks with real-time guarantees?



--
Best regards,
Maxim

Back to top
Daniel Tahin
Guest





PostPosted: Wed Feb 23, 2005 3:21 pm    Post subject: Re: task sheduling Reply with quote

What about programming a real-time task with C or C++ (e.g. under Linux)
and using JNI to communicate with the Java program?




Paul van Rossem wrote:
Quote:
It depends on your requirements.

1) If it is critical that your task starts with millisecond accuracy,
then for starters, you should not use a PC. Windows simply can't handle
this. And you should not be using Java. Java starts several threads that
compete for CPU-time. One of these is the garbage collector, that may
take a few millis or more, possibly just when your real-time task is due.

2) If your requirements are less critical, then by all means use Java.
In that case just compute the time to sleep (subtract the current time
from the planned activation time), and start a timer.
If your requirement is about seconds accuracy, and you are not running
any other programs, this should generally do the job.

3) Busy waiting is the worst option, it degrades system performance
quite heavily and, as you already found out, doesn't guarantee a thing.

Paul.

On 23-02-2005 12:42, Maxim Kasimov wrote:


i need to shedule some task at the determined time.
in api reference there is Timer class ( and TimerTask ),
but "This class does not offer real-time guarantees: it schedules
tasks using the Object.wait(long) method."

in my midlet, it is critical to shedule tasks at the certain time.

i think i should use System.currentTimeMillis(), and in run() check is
the time to shedule task.

is there some elegant way to shedule tasks with real-time guarantees?


Back to top
Display posts from previous:   
Post new topic   Reply to topic    AppletTalk.com Forum Index -> Java Help All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.