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<http://developer.android.com/reference/java/util/concurrent/ScheduledThreadPoolExecutor.html>
for
new code."
marcpolo, this illustrates why you should take advice with a grain of salt
and a
pound of verification.
'Timer' does not guarantee an exact interval, thus does not solve the OP's
problem.
marcpolo wrote:
>
> 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 post to the message queue using the postDelay command to schedule the
> next command for 25ms. My run method is as follows.
>
> @Override
> public void run()
> {
> m_handler.postDelayed(this, (int)m_samplePeriod_ms);
>
Underscores in variable names violate the Java Coding Conventions, with the
exception of constant variables.
> displayRangeData();
> }
> My timing measurements have shown that around half of the time the run
> method gets executed at 25ms intervals, whereas the rest are typically
> around 29-32ms.
>
> Is there a way to increase the priority of the Runnable thread so that I
> can achieve a consistent 40Hz?
>
> Am I being unrealistic in my expectations? I am running on a Samsung
> Galaxy S3.
>
> Are there other alternatives? I have tried using a thread but I run into
> problems when I try to update the UI.
>
What do you mean "tried using a thread"? Show us the code.
You certainly don't want to put that delay on the GUI thread.
Timing in a non-real-time system is approximate.
--
Lew
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en