java——Runnable接口多线程

/**
 * 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 在运行"); 
} 
} 
}

留下评论

您的邮箱地址不会被公开。 必填项已用 * 标注