码迷,mamicode.com
首页 > 编程语言 > 详细

爪哇国新游记之十二----线程创建的两种形式

时间:2014-07-25 13:49:21      阅读:177      评论:0      收藏:0      [点我收藏+]

标签:style   blog   color   art   re   c   div   ar   

public class Thread1 extends Thread{
    public void run(){
        int i=0;
        while(i<10){
            i++;
            System.out.println(i);
        }
    }
    
    public static void main(String[] args){
        Thread1 t=new Thread1();
        t.start();
    }
}
public class Thread2 implements Runnable{

    @Override
    public void run() {
        int i=10;
        while(i>0){
            i--;
            System.out.println(i);
        }
    }
    
    public static void main(String[] args){
        Thread2 t=new Thread2();
        new Thread(t).start();
    }
}

线程,较难讲透,初学者不易掌握,带过即可。

爪哇国新游记之十二----线程创建的两种形式,布布扣,bubuko.com

爪哇国新游记之十二----线程创建的两种形式

标签:style   blog   color   art   re   c   div   ar   

原文地址:http://www.cnblogs.com/xiandedanteng/p/3867499.html

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