My lecturer gave me an assignment asking for a multi threaded graphics program where a ball bounces around a jframe. He wanted each ball to have its own thread. Upon marking he told me that a timer is multi threaded and this is the best way to do this. I used a new Thread for each ball I know this is costly but he told us to use a thread for each ball. Is the timer class multi threaded?
using a timer
Ball b = new Ball(x, y);
BallMover bm = new BallMover(b)//adds the ball to a new instance of an actionListner
theTimer.addActionListener(bm);
using threads
Ball b = new Ball(x,y);
BallMover bm = new BallMover(b);//adds the ball to a new instance of a Thread
bm.start();