通过继承Thread类来创建线程

public class MyThread extends Thread 
{
public void run(){
for(int i=0;i<50;i++){
try{ Thread.sleep(100);}catch(Exception e){}
System.out.println(Thread.currentThread().getName()+" : "+i);
}
}
public static void main(String[] args)
{
MyThread t1 = new MyThread();
t1.start();
t1.run();//函数调用
}
}
posted @ 2012-03-19 11:34  haiwei.sun  阅读(255)  评论(0编辑  收藏  举报
返回顶部