我原来用线程的时候都是用其中的一个 前两天发现
public class Test extends Thread implements Runnable
{
public void run()
{
System.out.println("run");
}
public static void main(String args[])
{
Thread t=new Thread(new Test());
t.start();
}
}
运行很正常  会打印出一个 run
请教高手

解决方案 »

  1.   

    编译当然可以通过了。而且
    Test test=new Test();
    test.start();
    也可以实现同样功能。
      

  2.   

    在使用时,只能用到其中一个方法。
    如果用Thread t=new Thread(new Test());
    t.start();用到的是Runnable接口。
    如果用Test test=new Test();
    test.start();用到的是继承Thread
      

  3.   

    当然可以通过,因为继承什么和实现什么是没什么关系的,
    还有,你要看到new Thread(Runnable r)
    是以Runnable为引用的,也就是说只 要你实现了Runnable的接口就可以做为参数传入了
    哪怕你这个类是继承自Thread的
      

  4.   

    明白了
    start方法是Thread的
    实现runable接口的时候也是用的Thread的start方法