thread02

package cn.itcast.heima2;


public class ThaditionalThread {

public static void main(String[] args) {

Thread thread = new Thread(){
@Override
public void run() {
while(true){
try {
Thread.sleep(500);
} catch (InterruptedException e) {
e.printStackTrace();
}
System.out.println("111"+Thread.currentThread().getName());

}

}
};

thread.start();

Thread thread2 = new Thread(new Runnable() {

@Override
public void run() {
// TODO Auto-generated method stub
while(true){
try {
Thread.sleep(500);
} catch (InterruptedException e) {
e.printStackTrace();
}
System.out.println("222"+Thread.currentThread().getName());
}
}
});
thread2.start();

new Thread(
new Runnable() {

@Override
public void run() {
while(true){
try {
Thread.sleep(500);
} catch (InterruptedException e) {
e.printStackTrace();
}
System.out.println("444"+Thread.currentThread().getName());
}

}
}
){
@Override
public void run() {
while(true){
try {
Thread.sleep(500);
} catch (InterruptedException e) {
e.printStackTrace();
}
System.out.println("333"+Thread.currentThread().getName());
}
}
}.start();
}

}



發佈了19 篇原創文章 · 獲贊 2 · 訪問量 1萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章