Welcome to Srini's blog

Sunday, April 4, 2010

Choosing an approach between "extends Thread and implements Runnable"

The Thread class defines several methods that can be overridden by a derived class. Of these methods, the only one that must be overridden is run( ). This is, of course, the same method required when you implement Runnable. Many Java programmers feel that classes should be extended only when they are being enhanced or modified in
some way. So, if you will not be overriding any of Thread’s other methods, it is
probably best simply to implement Runnable. This is up to you, of course.

when you are going for multiple inheritance..the only interface can help, So creating thread class implements Runnable is best choice.

No comments:

Post a Comment