I'm writing a miniature golf game using double buffering. When the "ball" travels over the "hole", I set the thread to null and print "Congratulations!" on the screen. I want to make it so the user can click on the screen and try again (restart the thread). In my mousePressed method I set the Thread runner = new Thread (this); and then runner.start ();. This seems buggy...if the user clicks on the screen if the ball doesn't make it into the hole, the thread seems to go faster. Multiple clicking on the screen will make the ball go really fast. It can go so fast that it will shoot over the hole and not register that it was supposed to go in. Is there a way where you can just make the current thread stop until you tell it to restart?..instead of setting one thread to null then starting a new one. by the way, I'm implementing the Runnable interface...should I extend the Thread class? Will that give me more options? Thanks! ------------------ Michael J Bruesch Codito, ergo sum... I code, therefore I am. My Java Games, I'm quite proud
Michael J Bruesch<br /><i>I code, therefore I am.</i>
Joined: Sep 29, 2000
Why don't we move this over to the Threads forum for starters.
"JavaRanch, where the deer and the Certified play" - David O'Meara
Joined: Jan 05, 2001
There was a bunch of discussion about this on another thread. The only way I know of is to provide some exit condition from your run method using a member variable.