TestThread_5
来源:互联网 发布:药物靶点数据库 编辑:程序博客网 时间:2024/05/22 14:37
/**
*Title:TestThread_5
*Description:这个是开始一个线程的第二种方法注意区别第一种方法。
*@Copyright:
*@Company:
*@autor:firefly
*@vertion:1.0
*@time:2012.9.27
*/
public class TestThread_5 {
public static void main(String[] args) {
Runner1 r = new Runner1();
r.start(); //和TestThread_4不一样的是不用开始一个线程,因为Runnable1已经是一个线程。
for(int i = 1; i < 100; i++)
System.out.println("Main Thread:-----"+i);
}
}
class Runner1 extends Thread {//和TestThread_4不一样的是这里直接继承了线程。
public void run() {
for(int i = 0; i < 100; i++)
{
System.out.println("Runable = "+i);
}
}
}