- package lm.thread;
- /*
- * 程序的休眠
- */
- public class ThreadDemo5 {
- public static void main(String[] args) {
- Mythread5 th1 = new Mythread5();
- th1.start();
- }
- }
- class Mythread5 extends Thread {
- @Override
- public void run() {
- System.out.println("我要倒数啦");
- try {
- for (int i = 10; i >0; i--) {
- System.out.println(i);
- Thread.sleep(1000);
- }
- System.out.println("数完啦");
- } catch (InterruptedException e) {
- e.printStackTrace();
- }
- }
- }
复制代码 |
|