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

前端 未结 5 518
借酒劲吻你
借酒劲吻你 2021-02-07 16:15

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

Code:

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


        
5条回答
  •  梦毁少年i
    2021-02-07 17:02

    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.

提交回复
热议问题