Can't reenter android application with force close
<p>Basically every time I try to exit my application using the home button and then reenter it, it makes me force close the game before I can open the game up. I haven't been able to find out how to have it save the state when I leave the app, I need it to save an arraylist and some variables and booleans, but I don't know how to do it. Here is my activity and my surfaceCreated, Destroyed and stuff, the surfaceCreated is where the error is thrown, saying the thread is already open.</p>

<p>Here is the logcat</p>

<p>E/AndroidRuntime(  183): Uncaught handler: thread main exiting due to uncaught e
xception
E/AndroidRuntime(  183): java.lang.IllegalThreadStateException: Thread already s
tarted.
E/AndroidRuntime(  183):        at java.lang.Thread.start(Thread.java:1286)
E/AndroidRuntime(  183):        at com.Waldev.cannon.CannonBlast$panel.surfaceCr
eated(CannonBlast.java:515)
E/AndroidRuntime(  183):        at android.view.SurfaceView.updateWindow(Surface
View.java:392)
E/AndroidRuntime(  183):        at android.view.SurfaceView.onWindowVisibilityCh
anged(SurfaceView.java:182)
E/AndroidRuntime(  183):        at android.view.View.dispatchWindowVisibilityCha
nged(View.java:3745)
E/AndroidRuntime(  183):        at android.view.ViewGroup.dispatchWindowVisibili
tyChanged(ViewGroup.java:690)
E/AndroidRuntime(  183):        at android.view.ViewGroup.dispatchWindowVisibili
tyChanged(ViewGroup.java:690)
E/AndroidRuntime(  183):        at android.view.ViewRoot.performTraversals(ViewR
oot.java:694)
E/AndroidRuntime(  183):        at android.view.ViewRoot.handleMessage(ViewRoot.
java:1613)
E/AndroidRuntime(  183):        at android.os.Handler.dispatchMessage(Handler.ja
va:99)
E/AndroidRuntime(  183):        at android.os.Looper.loop(Looper.java:123)
E/AndroidRuntime(  183):        at android.app.ActivityThread.main(ActivityThrea
d.java:4203)
E/AndroidRuntime(  183):        at java.lang.reflect.Method.invokeNative(Native
Method)
E/AndroidRuntime(  183):        at java.lang.reflect.Method.invoke(Method.java:5
21)
E/AndroidRuntime(  183):        at com.android.internal.os.ZygoteInit$MethodAndA
rgsCaller.run(ZygoteInit.java:791)
E/AndroidRuntime(  183):        at com.android.internal.os.ZygoteInit.main(Zygot
eInit.java:549)
E/AndroidRuntime(  183):        at dalvik.system.NativeStart.main(Native Method)</p>

<pre><code>    @Override
    public void surfaceChanged(SurfaceHolder arg0, int arg1, int arg2, int arg3) {
        // TODO Auto-generated method stub

    }

    public void surfaceCreated(SurfaceHolder holder) {
        thread.setRunning(true);
        thread.start();
    }

    @Override
    public void surfaceDestroyed(SurfaceHolder holder) {
        // simply copied from sample application LunarLander:
        // we have to tell thread to shut down &amp; wait for it to finish, or else
        // it might touch the Surface after we return and explode
        boolean retry = true;
        thread.setRunning(false);
        while (retry) {
            try {
                thread.join();
                retry = false;
            } catch (InterruptedException e) {
                // we will try it again and again...
            }
        }
    }

public void onCreate(Bundle savedInstanceState) {
    final Window win = getWindow();
    super.onCreate(savedInstanceState);
    panelStuffz = new panel(this);
    requestWindowFeature(Window.FEATURE_NO_TITLE);
    win.setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN); 
    setContentView(panelStuffz);
}
@Override
public void onSaveInstanceState(Bundle savedInstanceState){
    super.onSaveInstanceState(savedInstanceState);
}

@Override
public void onRestoreInstanceState(Bundle savedInstanceState) {
     super.onRestoreInstanceState(savedInstanceState);
}
</code></pre>
