创建线程的方法

package Thread_Example;

class Xc extends Thread    //创建线程 所需要的类 
{
    public void run()
    {
        for(int i=0;i<25;i++)
        {
            System.out.println("子函数");
        }
    }

}
public class Thread_1 {
    public static void main(String[] args){
        Xc xc=new Xc();
        //xc.run();
        xc.start();        //谁调用 的start 方法,程序 就去调用run 方法
                        //start会开启一个线程,而不是 直接调用 
        for(int i=0;i<25;i++)
        {
            System.out.println("主函数");
        }
    }

}
原文地址:https://www.cnblogs.com/SGRBOY/p/10684936.html