I\'m making a game and i need to update the JProgressBar every 3 seconds. To do that i use a while loop. The problem is that my program freezes becuse of the while loop (i read
I'm not sure what you're trying to do with this program, but there you might want to investigate using a listener instead of rolling your own regular time interval. Also, if your while condition is simply true, it's probably a smell that there is a simpler way to implement the solution - messing with threads is playing with fire.
https://docs.oracle.com/javase/tutorial/uiswing/events/eventsandcomponents.html