多线程,休眠线程。

public class Demo03 {
public static void main(String[] args) throws InterruptedException {
Test01();
new Thread(){
public void run(){
for(int i = 0;i<10;i++){
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
e.printStackTrace();
}
System.out.println(this.getName()+"aaaaa");
}
}
}.start();
new Thread(){
public void run(){
for(int i = 0;i<10;i++){
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
e.printStackTrace();
}
System.out.println(this.getName()+"bbbbbbb");
}
}
}.start();
}
public static void Test01() throws InterruptedException {
for(int i = 20; i >= 0; i--){
Thread.sleep(1000);
System.out.println("倒计时第"+i+"秒");
}
}
}
posted @ 2020-07-20 21:45  一块  阅读(55)  评论(0编辑  收藏