Java: while loop freezes program

前端 未结 3 975
鱼传尺愫
鱼传尺愫 2021-01-29 06:50

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

3条回答
  •  一个人的身影
    2021-01-29 06:59

    You should run your loop in an own Thread:

            new Thread( new Runnable() {
                @Override
                public void run()
                {
                    resourceLoader (null);
                }}).start();
    

    BTW: If you do not use the "String[] args" in the method there is no reason to have it declared in the method.

提交回复
热议问题