public class test implements Runnable {
Thread th;
public void run() {
try {
System.out.printf("100");
Thread.sleep(1000);
System.out.printf("\r");
Thread.sleep(1000);
System.out.printf("200");
} catch (Exception e) {
System.out.println(e);
}
}
public static void main(String[] args) throws Exception {
Thread th = new Thread(new test());
th.start();
}
}
[Java] Java簡單的Sleep使用
本文提供了一个Java线程示例,展示了如何创建并启动一个线程来执行特定任务,包括打印输出和使用sleep方法实现延时。

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



