Java中实现延时一段时间:
try {
Thread.currentThread().sleep(1000); //毫秒
} catch (Exception e) {
e.printStackTrace();
}
本文介绍了一种在Java中实现线程延时的方法。通过使用Thread类的currentThread().sleep(毫秒数)方法,可以轻松地让当前线程暂停指定的时间。
Java中实现延时一段时间:
try {
Thread.currentThread().sleep(1000); //毫秒
} catch (Exception e) {
e.printStackTrace();
}
821
6180
1806

被折叠的 条评论
为什么被折叠?