1. 程式人生 > 資訊 >NASA 尋求修復哈勃太空望遠鏡軟體問題

NASA 尋求修復哈勃太空望遠鏡軟體問題

 1 package multithread4;
 2 
 3 
 4 /*
 5 class Test implements Runnable{
 6     public  void run(Thread t) {
 7         
 8     }
 9 }*/
10 //如果錯誤,錯誤發生在哪一行,錯誤在第一行,應該被abstract修飾 run方法沒被覆蓋,
11 public class ThreadTest {
12 
13     public static void main(String[] args) {
14         // TODO Auto-generated method stub
15 new Thread(new Runnable() { 16 17 @Override 18 public void run() { 19 System.out.println("runnable run"); 20 21 } 22 }) { 23 public void run() { 24 System.out.println("subThread run");//
以子類為主 輸出subThread run 25 } 26 }.start(); 27 /*new Thread() { 28 public void run() { 29 for (int x = 0; x < 50; x++) { 30 System.out.println(Thread.currentThread().getName()+"x="+x); 31 } 32 } 33 }.start();
34 35 for (int x = 0; x < 50; x++) { 36 System.out.println("y="+x); 37 } 38 Runnable r = new Runnable() { 39 40 @Override 41 public void run() { 42 for (int x = 0; x < 50; x++) { 43 System.out.println(Thread.currentThread().getName()+"z="+x); 44 } 45 } 46 }; 47 new Thread(r).start(); 48 */ 49 } 50 51 }
ThreadTest