码迷,mamicode.com
首页 > 其他好文 > 详细

Thread

时间:2017-04-23 18:15:16      阅读:151      评论:0      收藏:0      [点我收藏+]

标签:color   ati   tar   div   this   run   art   thread   style   

 

 

 1 package MyThread;
 2 import java.lang.*;
 3 public class MyThread extends Thread{
 4     private String name;
 5     public MyThread(String name){
 6         this.name = name;
 7     }
 8     public void run(){
 9         
10     for(int i=0;i<5;i++){
11         System.out.println(name+i);
12     }
13     }
14     public static void main(String[] args) {
15 
16 
17     }
18 
19 }

 

 

 1 package MyThread;
 2 
 3 public class ThreadTest {
 4 
 5     public static void main(String[] args) {
 6         MyThread t1 = new MyThread("线程A");
 7         MyThread t2 = new MyThread("线程B");
 8         
 9         t1.start();
10         t2.start();
11         
12         for(int i=0;i<5;i++){
13             System.out.println("主线程"+i);
14         }
15 
16 
17     }
18 
19 }

 

Thread

标签:color   ati   tar   div   this   run   art   thread   style   

原文地址:http://www.cnblogs.com/the-wang/p/6752991.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!