How many threads should an Android game use?

Posted by kvance on Game Development See other posts from Game Development or by kvance
Published on 2010-07-14T19:43:24Z Indexed on 2011/11/11 18:29 UTC
Read the original article Hit count: 181

Filed under:
|
|

At minimum, an OpenGL Android game has a UI thread and a Renderer thread created by GLSurfaceView. Renderer.onDrawFrame() should be doing a minimum of work to get the higest FPS. The physics, AI, etc. don't need to run every frame, so we can put those in another thread. Now we have:

  1. Renderer thread - Update animations and draw polys
  2. Game thread - Logic & periodic physics, AI, etc. updates
  3. UI thread - Android UI interaction only

Since you don't ever want to block the UI thread, I run one more thread for the game logic. Maybe that's not necessary though? Is there ever a reason to run game logic in the renderer thread?

© Game Development or respective owner

Related posts about android

Related posts about multithreading