We know we can implement thread either by extending the Thread class or implementing Runnable interface, but which one is better and when to use one? This question will be easy to answer if you know that the Java programming language doesn't support multiple inheritances of class, but it allows you to implement multiple interfaces.
This means it's better to implement Runnable than extend Thread if you also want to extend another class e.g. Canvas or CommandListener.
No comments:
Post a Comment