从我在 Java 中使用线程的时间开始,我发现了这两种编写线程的方法:
使用implements Runnable :
public class MyRunnable implements Runnable {
public void run() {
//Code
}
}
//Started with a "new Thread(new MyRunnable()).start()" call或者,使用extends Thread :
public class MyThread extends Thread {
public MyThread() {
super("MyThread");
}
public void run() {
//Code
}
}
//Started with a "new MyThread().start()" call这两个代码块有什么显着差异吗?