Thread + 匿名內部類


package chapter01;

public class MyThread01 extends Thread{

@Override
public void run() {
//讓當前線程執行的代碼編寫在run方法中

for(int i=0; i<=100; i++) {
System.out.println("發微信" + i);
}
}

}

--------------------------

package chapter01;

public class MyThread02 extends Thread{

@Override
public void run() {
for(int i=0;i<=100;i++){
System.out.println("qq"+i);
}
}

}

---------------------------、

package chapter01;

public class MyThread02 extends Thread{

@Override
public void run() {
for(int i=0;i<=100;i++){
System.out.println("qq"+i);
}
}

}

----------------------------

package chapter01;

/**
* Thread + 匿名內部類
*/
public class TestThread02 {

public static void main(String[] args) {
// 匿名內部類
Thread thread = new Thread() {

@Override
public void run() {
for (int i = 0; i <= 100; i++) {
System.out.println("++++++++" + i);
}
}

};
thread.start();
new Thread() {

@Override
public void run() {
for (int i = 0; i < 100; i++) {
System.out.println("-------" + i);
}
}

}.start();

}

}


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM