Win a copy of Java 9 Revealed this week in the Features new in Java 9 forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

java.lang.IllegalThreadStateException: Thread already started  RSS feed

 
jite eghagha
Ranch Hand
Posts: 128
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi,

Here's what i'm doing.

From HomeActivity, using an Intent, i start MenuActivity


In MenuActivity, i create an instance of GameView, which extends SurfaceView

GameView is a video game, and so it is passed to GameLoopThread which extends Thread (GameLoopThread calls onDraw() over and over to move Sprites).

Below is the run method in GameLoopThread.



When i click on a Sprite, i start ItemActivity using an Intent

When i click on the back button on my phone i expect to exit the ItemActivity and return to the GameView g, but i get the "Thread already started error"

The error is occurs in GameView g in a SurfaceHolders Callback method.


There error causes me to ask....
How do i handle the Thread that GameView g is running in? Can i kill it?, can it sleep?, what happens to it when ItemActivity is destroyed and MenuActivity (GameView g) is brought back to the front.





 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!