Possible Duplicate:
Java: “implements Runnable” vs. “extends Thread”
Should I use Runnable interface or extends from Thread class? Is there any advantage on one and another?
Thanks in advance.
Possible Duplicate:
Java: “implements Runnable” vs. “extends Thread”
Should I use Runnable interface or extends from Thread class? Is there any advantage on one and another?
Thanks in advance.
As far as I know it's just a matter of preference.
My own preference is to pass a Runnable, because I don't like the subclassing approach nor the fact that Thread implements Runnable. (Subclassing Thread to implement run()
abuses the "is-a" relationship that subclassing is supposed to represent. Making Thread implement Runnable doesn't really add any value, and it allows for nonsensical things like using one thread as the runnable construction parameter of another thread.)