android - Syncing UI Thread and workhorse thread -


hi have 1 thread uses surfaceview draw screen thread updating positions of objects on screen. how make these run @ same speed?

there trade off:

  • you want update screen sufficiently motion appears smooth.
  • you want give cpu possible workhorse thread

the easy solution this:

  1. the work horse thread sets flag indicating when there has been change worthy of redraw.
  2. the ui thread has flow bit this

    do {     renderscreen();     while (!screenneedsredrawing) {         thread.sleep(10);     } } 

Comments

Popular posts from this blog

php - Calling a template part from a post -

Firefox SVG shape not printing when it has stroke -

How to mention the localhost in android -