Possible Duplicate:
Java: “implements Runnable” vs. “extends Thread”
When should you use:
class MyThread extends Thread {
public void run() {
System.out.println("Important job running in MyThread");
}
public void run(String s) {
System.out.println("String in run is " + s);
}
}
over:
class MyRunnable implements Runnable {
public void run() {
System.out.println("Important job running in MyRunnable");
}
}
Obviously we instantiate these differently but is there any difference once they are created?
Threadis a class that implementsRunnableinterface. Essentially, that means that this is allowable:By implementing a
Runnable, you’re essentially have to implement therun()method for the Thread to execute it.Other than that, I don’t know what you’re really asking.