File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

threads

 
chaitanyakumar gajjar
Greenhorn
Posts: 2
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
to create thread class wich method is best extends thread or
implements runnble. why?
 
Sivaram Ghorakavi
Ranch Hand
Posts: 56
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Implementing Runnable interface is much lighter than extending Thread. Lighter in the sence the over head of Thread class members etc... More over if you extend Thread class you loose the option of extending any other calss. But implementing Runnable will give you this choice.
 
Rajiv Ranjan
Ranch Hand
Posts: 61
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think implementing runnable interface is a better way.
One simple reason I can think of is multiple inheritence.If you extend a thread class , you cannot extend any more classes (limitation of Java) but if you implement runnable interface you can implement more interfaces.
I guess this question is discussed in RHE preety well.
 
chaitanyakumar gajjar
Greenhorn
Posts: 2
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks for ans but can some body explain same with a simple
example
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic