首页 > 编程语言 > 详细

多线程问题匿名内部类

时间:2017-03-15 16:01:12      阅读:262      评论:0      收藏:0      [点我收藏+]
 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 }

 

多线程问题匿名内部类

原文:http://www.cnblogs.com/javatrain/p/6554675.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!