从我在Java
中花在线程上的时间开始,我找到了这两种编写线程的方法:
implements 100:
public class MyRunnable implements Runnable {
public void run() {
//Code
}
}
//Started with a "new Thread(new MyRunnable()).start()" call
或者,用extends 100:
public class MyThread extends Thread {
public MyThread() {
super("MyThread");
}
public void run() {
//Code
}
}
//Started with a "new MyThread().start()" call
这两段代码有什么显著区别吗?