java——Runnable接口多线程

2019年2月17日19:19:04 发表评论 1,046 views
/**
 * Created by xabcd on 2019/2/17.
 */
public class threaddemo_2 {
    public static void main(String args[])
    {
        testthread t =new testthread();
                new Thread(t).start();//通过testthread类去实例化一个Thread类的对象,然后调用staart()方法启动多线程
for (int i=0;i<10000;i++)
 { System.out.println("main线程在运行"); 
}
 } 
}
 class testthread implements Runnable 
{ public void run()
{ for (int i = 0; i < 10000; i++) 
{ System.out.println("TestThread 在运行"); 
} 
} 
}

发表评论

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen: