如何在Java中暂停当前线程20秒?

6

如何在Java中暂停当前线程20秒钟?

3个回答

20


3

您可能还需要包含 try catch 语句:

try {
  Thread.sleep(20*1000);
} catch(InterruptedException e) { }

3
应该使用InterruptedException,而不是一般的所有异常。 - Jason S

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接