通过继承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();//函数调用
}
}