In my old game based on canvas and bitmaps I used surfaceHolder and Thread to call onDraw:

public class GameThread extends Thread {
private SurfaceHolder _surfaceHolder;
private ScreenObjectsView _panel;
private boolean _run = false;

public static int mOnDrawPeriodGap = 20;

public GameThread(SurfaceHolder surfaceHolder, ScreenObjectsView panel) {
    _surfaceHolder = surfaceHolder;
    _panel = panel;

public void setRunning(boolean run) {
    _run = run;

public SurfaceHolder getSurfaceHolder() {
    return _surfaceHolder;

public void run() {
    Canvas c;
    while (_run) {


        c = null;
        //Log.e("test","thread running");
        try {
            c = _surfaceHolder.lockCanvas(null);
            synchronized (_surfaceHolder) {

                /** onDraw() method  run too fast, lets slower it*/
                try {
                } catch (InterruptedException e) {
        } finally {
            // do this in a finally so that if an exception is thrown
            // during the above, we don't leave the Surface in an
            // inconsistent state
            if (c != null) {


Today I try to adapt my game to openGL 2D. I'm new in openGL world.

Do I need to do the same for new framework?

As I know It (openGL) seems already starts a second thread for rendering, calling into the Renderer methods.

Thank you,



Browse other questions tagged .