public static void delay_ms(int nms){
try {
Robot r = new Robot();
r.delay(nms);
} catch (Exception e) {
}
}
Thread.sleep(1000*3); // 休眠3秒
本文介绍了一种在Java中实现延迟执行的方法,通过使用Robot类和Thread.sleep()函数,可以精确控制程序的暂停时间,适用于需要定时操作或延时任务的场景。
public static void delay_ms(int nms){
try {
Robot r = new Robot();
r.delay(nms);
} catch (Exception e) {
}
}
Thread.sleep(1000*3); // 休眠3秒
663

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