多线程,休眠线程。

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+"秒");
}
}
}
原文地址:https://www.cnblogs.com/wangffeng293/p/13347991.html