黑色星球
风遇浪,海市蜃楼
 1 public class ThreadD {
 2 
 3     public static void main(String args[]) {
 4         MyThread r = new MyThread();
 5         // r.start();
 6         // Runable接口作为匿名内部类使用时,多线程未启动,原因是什么呢
 7         Runnable x = new Runnable() {
 8             public void run() {
 9                 for (int i = 0; i < 500; i++) {
10                     System.out.println("-------------------------" + i);
11                 }
12 
13             }
14         };
15         Thread t = new Thread(x);
16         t.start();
17         for (int i = 0; i < 500; i++) {
18             System.out.println("中" + i);
19 
20         }
21     }
22 
23     // 实现方法使用
24     public static class Myrunable implements Runnable {
25 
26         @Override
27         public void run() {
28             // TODO Auto-generated method stub
29             for (int i = 0; i < 500; i++) {
30                 System.out.println("-------------------------" + i);
31 
32             }
33         }
34 
35     }
36 }

 

posted on 2017-03-15 15:54  黑色星球  阅读(369)  评论(0编辑  收藏  举报