多线程,休眠线程。
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+"秒");
}
}
}
添加微信进交流群: opiopi293