@Override public void surfaceCreated(SurfaceHolder holder) { if (thread.getState() == Thread.State.TERMINATED) { thread = new GameLoopThread(); } // start the game loop thread.setIsRunning(true); thread.start(); }
// SurfaceHolder.Callback methods: @Override public void surfaceCreated(SurfaceHolder surfaceHolder) { // thread exists, but is in terminated state if (thread.getState() == Thread.State.TERMINATED) { thread = new GameLoopThread(); } // start the game loop thread.setIsRunning(true); thread.start(); }
@Override public void surfaceDestroyed(SurfaceHolder holder) { boolean retry = true; thread.setIsRunning(false); while (retry) { try { thread.join(); retry = false; } catch (InterruptedException e) { } } }