How to make a thread sleep for specific amount of time in java?

前端 未结 5 905
盖世英雄少女心
盖世英雄少女心 2021-02-07 16:19

I have a scenario where i want a thread to sleep for specific amount of time.

Code:

    public void run(){
        try{
            //do something
               


        
5条回答
  •  情书的邮戳
    2021-02-07 17:11

    Why do you want to sleep for exactly 3 seconds? If it's just having to execute something after some time, try using a Timer.

提交回复
热议问题