Re: [android-developers] Re: Handler - Runnable Performance Issues at 40Hz

2012-10-31 Thread Kristopher Micinski
It's not an RTOS thing, it's more of a Java thread scheduler thing, so this happens closer to the framework level. kris On Wed, Oct 31, 2012 at 12:05 PM, marcpolo wrote: > I used java.util.Timer and TimerTask instead of the Runnable and this > resulted in much improved performance, allowing me t

[android-developers] Re: Handler - Runnable Performance Issues at 40Hz

2012-10-31 Thread marcpolo
I used java.util.Timer and TimerTask instead of the Runnable and this resulted in much improved performance, allowing me to schedule the task at 40Hz (on average). As expected, given this is not a RTOS, the cycles vary +/-1-2ms, however I the the average cycle time is 25ms as desired. So, it

[android-developers] Re: Handler - Runnable Performance Issues at 40Hz

2012-10-31 Thread bob
Why not just use post instead of postDelayed? That's what I use to update display of the battery level every 10 seconds: public class Battery_Level_Thread extends Thread { @Override public void run() { while (true) { MainActivity.handler.post(new Runnable() { @Override public void run() { Mai

Re: [android-developers] Re: Handler - Runnable Performance Issues at 40Hz

2012-10-30 Thread Kristopher Micinski
On Tue, Oct 30, 2012 at 8:10 PM, marcpolo wrote: > I appreciate that android is not a realtime system but thought that 40Hz > wouldn't be too difficult to achieve, with the occasional overrun, which > wouldn't impair my app. I am getting nowhere near this - even when I remove > the range measureme

[android-developers] Re: Handler - Runnable Performance Issues at 40Hz

2012-10-30 Thread marcpolo
Thanks very much for the feedback. When I mentioned that I used a thread, I meant that I extended the Thread class with the run() method being overriden. I'm at home at the moment so can't show some code. Basically I would start/stop the thread from a button 'click' handlers. Inside the Run()

[android-developers] Re: Handler - Runnable Performance Issues at 40Hz

2012-10-30 Thread Lew
bob wrote: > Sounds like you want a java.util.Timer > > http://developer.android.com/reference/java/util/Timer.html "This class does not offer guarantees about the real-time nature of task scheduling." "Prefer ScheduledThreadPoolExecutor

[android-developers] Re: Handler - Runnable Performance Issues at 40Hz

2012-10-30 Thread bob
Sounds like you want a java.util.Timer On Tuesday, October 30, 2012 2:41:05 PM UTC-5, marcpolo wrote: > > Hi, > > I'm developing an application to perform range measurements at 40Hz and > display them on a UI. > > To achieve this I have created a Runnable class to perform each cycle and > I pos