Re: Timers/Thread preformance?
Posted By:
Anonymous
Posted On:
Sunday, August 29, 2010 09:35 AM
near the availible 40ms, sometime more
Re: Timers/Thread preformance?
Posted By:
hari_haran
Posted On:
Friday, May 14, 2004 07:12 AM
hay,
I have a small logic for you....just try implementing this, what you do is create a SCHEDULER THREAD which extends a normal Thread class, now in run method keep a while loop and make it sleep for 35 milli seconds, now keep a static hash map or a vector according to your convinence, and store the thread in that, which needs to be invoked every 40 milliseconds(Let us call it it Thread "A" ). For every 35 milliseconds try to check whether the Thread "A" is running or not If its running just dont do any task, if its not running call start on it.
now, how to know whether a thread is running or not explictly?
the answer would be keep a boolean flag in Thread "A", and change it to true in the start of run() method and false at the end of run() method.
If u require more info harihkrishna@yahoo.com
Re: Timers/Thread preformance?
Posted By:
Rajeev_Mahajan
Posted On:
Thursday, January 9, 2003 08:10 AM
In a normal setup this is not possible. You can get some more close result by turning of the GC (be careful if you turn it off). or else you will have to use real time java. Also search for some real time apis in java. java.util.Timer class does not offer real-time guarantees: it schedules tasks using the Object.wait(long) method
Rajeev
Re: Timers/Thread preformance?
Posted By:
Shashi_Bhusan
Posted On:
Friday, November 30, 2001 01:02 AM
As per your requirements I feel you should use java threads. I have used threads on many such problems, ofcourse not at 40 ms. As documented in Java API "If a timer task takes excessive time to complete, it "hogs" the timer's task execution thread. This can, in turn, delay the execution of subsequent tasks, which may "bunch up" and execute in rapid succession when (and if) the offending task finally completes.". This is just opposite to your requirements.
Moreover This class does not offer real-time guarantees: it schedules tasks using the Object.wait(long) method. Thread.sleep() method is quite reliable for your usage. Hope this helps you