I know that implements Runnable is preferred over extends Thread in Java threads as it allows us to extend some other class if it is required. But if this is the case, does extends Thread also have its own advantages over implements Runnable and if so, what are these advantages?
Answer
Because sometimes (almost never, but sometimes) you want to be able to change the basic behaviour of Thread.
That's when you'll need to extend it.
You can change it by overriding a method from the Thread class, you can't do it by implementing one from Runnable.
No comments:
Post a Comment