Program: Bouncing Ball - Each click of button adds a moving ball onto a component
Goal: To stop all threads when i click on a stop button
When go button is clicked, the following is performed:
Bounce ball = new Bounce(); comp.add(ball); Runnable run = new BallRunnable(ball, comp); t = new Thread(run); t.start();
When user clicks go again, it will add the new ball. I've only allowed 10 balls to be placed, as my button will Gray-out after 10 clicks.
I've tried invoking .interrupt on 't', but only stops ONE ball on the screen because i only use one instance of Thread throughout.
Could anyone please shed light on how it would be possible to stop and clear ALL of the balls on the screen, not just one.
My initial thought it to possibly implement a generic ArrayList of type Thread, but not sure how to go about it.
Thanks a bunch for your time.