我已经写了下面的例子:为什么不运行方法调用?
public class MyThread extends Thread{
MyThread(Runnable r){
super(r);
}
public void run(){
System.out.println("run");
}
}
public static void main(String[] args)
{
Thread t = new MyThread(new Runnable() {
@Override
public void run() {
System.out.println("rrrrrrrrrruuuuuuuuuuuun");
}
});
t.start(); //run
}
为什么在MyThread
定义运行methdo叫呢?
@ practice2perfect我已经写了叫MyThread的,只是导入他到主一个单独的类。 – 2014-10-05 14:15:14
为什么不是你的主要方法封装到一个类? – 2014-10-05 14:18:49
@Fev它只是一个Main类的一个片段和一个分离的MyThread类。 – 2014-10-05 14:19:25