A股上市公司传智教育(股票代码 003032)旗下技术交流社区北京昌平校区

 找回密码
 加入黑马

QQ登录

只需一步,快速开始

© 大奔 中级黑马   /  2015-2-4 19:03  /  820 人查看  /  0 人回复  /   0 人收藏 转载请遵从CC协议 禁止商业使用本文

class Demo extends Thread
{
        //private String name;
        Demo(String name)
        {
                //this.name=e;
               
                super(name);
                System.out.println(this.name);
        }
        public void run()
        {
                //for(int x=0;x<=1;x++)
                        //System.out.println(this.getName()+"run.."+x);
        }
}
class ThreadDemo
{
        public static void main(String [] args)
        {
                //for(int x=0;x<=90;x++)
                //        System.out.println("Demo run"+x);
                Demo d1=new Demo("one..............");
                Demo d2=new Demo("two.....................");
                d1.start();            //开启线程并执行线程的run方法
                //d.run(); 仅仅是对象调用方法 线程创建了,但并未执行  
                d2.start();
                //for(int x=0;x<=1;x++)
                        //System.out.println("Demo run"+x);
        }
}

0 个回复

您需要登录后才可以回帖 登录 | 加入黑马