@Overridepublic void run() {Canvas canvas;Log.d("ghj", "Starting game loop");while (running) {canvas = null;// try locking the canvas for exclusive pixel editing// in the surfacetry {canvas = this.surfaceHolder.lockCanvas();synchronized (surfaceHolder) {// update game state this.gamePanel.update();// render state to the screen// draws the canvas on the panelthis.gamePanel.render(canvas);}} finally {// in case of an exception the surface is not left in // an inconsistent stateif (canvas != null) {surfaceHolder.unlockCanvasAndPost(canvas);}}// end finally}}}