Pausing thread on ExitDialog
<p>What should I do to call thread's  <code>pause()</code> method from <code>showExitDialog()</code> here ?
Here's Start Game class </p>

<pre><code>package game.mainmenu;


import game.view.ViewPanel;
import android.app.Activity;
import android.app.AlertDialog;
import android.content.DialogInterface;
import android.os.Bundle;
import android.view.KeyEvent;
import android.view.Window;
import android.view.WindowManager;

public class StartGame extends Activity {
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        requestWindowFeature(Window.FEATURE_NO_TITLE);
        getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN );

        setContentView(new ViewPanel(this));      

    }

    @Override
    protected void onPause() {
        super.onPause();
        //saveScores();
        this.finish();
        System.exit(1);// pause game when Activity pauses
    }


    @Override
    public boolean onKeyDown(final int pKeyCode, final KeyEvent pEvent) {

        if (pKeyCode == KeyEvent.KEYCODE_BACK
                &amp;&amp; pEvent.getAction() == KeyEvent.ACTION_DOWN) {
            showExitDialog();

            return true;
        }

        return super.onKeyDown(pKeyCode, pEvent);
    }

    public void showExitDialog() {
        AlertDialog.Builder builder = new AlertDialog.Builder(StartGame.this);
        builder.setMessage("Are you sure you want to exit?")
                .setCancelable(false)
                .setTitle("EXIT")
                .setPositiveButton("Yes",
                        new DialogInterface.OnClickListener() {
                            public void onClick(DialogInterface dialog, int id) {
                                StartGame.this.finish();
                            }
                        })
                .setNegativeButton("No", new DialogInterface.OnClickListener() {
                    public void onClick(DialogInterface dialog, int id) {
                        dialog.cancel();
                    }
                });

        AlertDialog alert = builder.create();
        //alert.setIcon(android.R.drawable.star_on);
        alert.show();

    }
}
</code></pre>

<p>Here's class with main thread</p>

<pre><code>public class ViewManager extends Thread 
{
    //some states here
    public static final int STATE_LOSE = 1;
    public static final int STATE_PAUSE = 2;
    public static final int STATE_READY = 3;
    public static final int STATE_RUNNING = 4;
    public static final int STATE_WIN = 5;

    //..some not mention code here../

    public ViewManager(SurfaceHolder surfaceHolder, Context context)
    {
        mSurfaceHolder = surfaceHolder;
        mRunning = false;
        mHealthBar = new Rect(0,0,0,0);
        mLinePaint = new Paint();
        mLinePaint.setAntiAlias(true);
        mLinePaint.setARGB(255, 0, 255, 0);
        mLinePaint.setTextSize(16);
        mLinePaint.setStrokeWidth(3);
        mContext = context;
        Resources res = context.getResources();

        //..some not mention code here../
        InitElements(res);

        mHero = new PlayerAnimated(mPlayerImage, FIELD_WIDTH/2, 600, 64, 64, 3, 3, context, mEnemiesList);
        //mBoom = new Explosion(mExplosionImage, 200, 500, 64, 64, 7, 7);
        mEnemyImage = BitmapFactory.decodeResource(res, R.drawable.enemyone);

        setState(STATE_RUNNING);

    }


    /**
        * threads state
        * @param running
        */
       public void setRunning(boolean running)
       {
           mRunning = running;
       }

       //..some not mention code here../

       public void run()
       {
           while (mRunning)
           {
               Canvas canvas = null;
               try
               {
                   // подготовка Canvas-а
                   canvas = mSurfaceHolder.lockCanvas();
                   synchronized (mSurfaceHolder)
                   {
                       if(mMode == STATE_RUNNING){

                           // draw if not paused
                           addEneimes(mContext);

                           updateStuff();

                           doDraw(canvas);
                       }
                       else
                       {
                           pauseDraw(canvas);
                       }
                       ViewPanel.displayFps(canvas, aString);

                       aString = Integer.toString(hudscore.getScore());

                   }
               }
               catch (Exception e) { }
               finally
               {
                   if (canvas != null)
                   {
                       mSurfaceHolder.unlockCanvasAndPost(canvas);
                   }
               }
           }
       }

       //..some not mention code here../

    public void pause() {
        synchronized (mSurfaceHolder) {
           setState(STATE_PAUSE);
           mLastFiredTime = System.currentTimeMillis() + 100;
        }
    }

    public void unpause() {
        //
        synchronized (mSurfaceHolder) {
            setState(STATE_RUNNING);
            mLastFiredTime = System.currentTimeMillis() + 100;
        }
    }

    public void setState(int mode) 
    {
        mMode = mode;
    }

    public void pauseDraw(Canvas canvas)
    {
         canvas.drawBitmap(Bitmap.createBitmap(FIELD_WIDTH, FIELD_HEIGHT, Bitmap.Config.RGB_565), 0, 0, null);
    }
}
</code></pre>
