TNT Explosives. LTD
TNT Explosives. LTD

Reputation: 1

Android thread.join() thread force closes when app started again

I have a problem with my app. I have a SurfaceHolder for drawing onto a canvas.
Under the surfaceCreated method, I call thread.start();
Under the surfaceDestroyed method, I call thread.join();
I run my app and press the home key, whoch in turn invokes the surfaceDestroyed method.

The problem is that I get a thread already started exception when I subsequently try and run my app again. Why is this? I am even testing to see if the thread is already running using isAlive(). Do I need to replace the thread.join line with a thread.wait?
If so, how can I resume the thread instead of starting it again in surfaceCreated?

Upvotes: 0

Views: 974

Answers (1)

MByD
MByD

Reputation: 137362

First - the wait method will not cause the thread to hang.
Second - join waits for the thread to die.
Third - I would consider creating a new thread, and not trying to run the same one.

Upvotes: 1

Related Questions