Working with threads.
Okay, I'm trying to set a cool little animation.
Basically, when the user presses down space, a boolean "req" is set to true, and a thread is started. The run() method is in the same class. The run method consists of a while loop which runs as req == true. When the user released the space bar, req is set to false, which I hoped would end the while loop, but instead it continues to loop. I used some System.out.println(req) tests along the way, and found that the thread thinks that req is set to true the entire time, even after releasing the space bar. How can I make it so that the while loop stops running after the space bar is released. (And yes, there has to be a while loop).
I... just figured out.... what happened.... I think I have a concussion... because I face palmed so hard.... I honestly, don't want to say what I did wrong, but trust me, it was stupid. But yeah, it works flawlessly now!
I think threads in java have their own scopes and that's why you get this error. Try checking the req variable directly from the superclass like:
I think this may work...
// Record the animation
Thanks for replying, but as I said, I figured it out. It was a really silly mistake, that only someone like me would make. I do these kinds of things all the time. In fact, I've made this exact same typo about 6 times tonight.