How many threads should an Android game use?
- by kvance
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:
Renderer thread - Update animations and draw polys
Game thread - Logic & periodic physics, AI, etc. updates
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?