Every time you click, you are starting a new Thread, which means you have another thread updating the x/y positions.
For example, 1 thread means your update the x/p once per sync, 2 means you're updating the x/y position at least twice per cycle and this just gets compounded each time you add a new thread.
A better solution would be to start the Thread
at some time earlier and then use a List
to maintain the position and direction of the ball.
This will require a little but synchronisation to keep things safe
FYI a delay of 40 milliseconds is roughly 25 fps, 16 milliseconds is roughly 60 fps. IMHO, for what you are doing, 10 milliseconds seems excessive...