I want to know if this is a good practice or not.
I am making a simple Invader game where you shoot laser beams at incoming invaders. I have made a class called LaserBeam which implements Runnable i.e each laser beam will have it's own thread.
My main class contains an ArrayList of all LaserBeam objects and contains a paintComponent method that updates whats happening onscreen.
Now that each beam is on a seperate thread I was thinking about passing a reference of the main class into LaserBeam so each beam can call MainClass.repaint() when it's position changes i.e every 40ms or so it moves 2 pixels up and this needs to be repainted.
Personally I wouldn't use any threads at all for the laser beams, and just one dedicated loop that updates your entire model state, and tells the UI to repaint(). You can use java.util.Timer to schedule updates at a fixed rate, or to keep running the updates as fast as possible.