0125 多线程 继承Thread 练习

时间:2016-01-25 18:49:49   收藏:0   阅读:128
//定义一个继承Thread类的类,并覆盖run()方法,在run()方法中每隔100毫秒打印一句话
public
class Csh extends Thread{ public void run(){ outInfo(); } private void outInfo() { for(int i=0;i<21;i++){ System.out.println("我最聪明"); try { Thread.sleep(100); } catch (InterruptedException e) { e.printStackTrace(); } } } public static void main(String[] args) { Csh m = new Csh(); m.start(); Csh n = new Csh(); n.start(); } }

 

原文:http://www.cnblogs.com/sjxx/p/5157849.html

评论(0
© 2014 bubuko.com 版权所有 - 联系我们:wmxa8@hotmail.com
打开技术之扣,分享程序人生!