On Jan 11, 2:25 am, "Dianne Hackborn" <[email protected]> wrote:
> Fwiw, you should generally avoid trying to directly control scheduling.  Let
> the kernel schedule the threads as needed; the only issue you had here was
> that your main thread was using as much CPU as it could get, since it was
> continually processing touch events, so the kernel would schedule 50/50
> between that and the game thread.  Simply reducing the work being done by
> the main thread (by our little hacky sleep solution) is probably the best
> way to fix things.

Thank you so much for this thread! It's very very helpful to me.

In my game I was getting 85 touch events per second, but I only use 1
per frame so what I've done is to synchronize my game thread with the
UI thread using Object.wait(1000L) at the end of my onTouchEvent().
The game thread uses notify() and then yields once per frame so that
the UI thread can fetch another event, so it effectively turns it into
a polling model. So now I'm getting 60 touch events per second, which
doesn't sound that different from 85, but the regularity does make a
substantial difference to the smoothness of my frame rate.

Thanks again!

--
Jon

--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to