This week's book giveaway is in the OCPJP forum.
We're giving away four copies of OCA/OCP Java SE 7 Programmer I & II Study Guide and have Kathy Sierra & Bert Bates on-line!
See this thread for details.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes threads Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "threads" Watch "threads" New topic
Author

threads

chaitanyakumar gajjar
Greenhorn

Joined: Jan 02, 2001
Posts: 2
to create thread class wich method is best extends thread or
implements runnble. why?
Sivaram Ghorakavi
Ranch Hand

Joined: Nov 30, 2000
Posts: 56
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

Joined: Sep 28, 2000
Posts: 61
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

Joined: Jan 02, 2001
Posts: 2
thanks for ans but can some body explain same with a simple
example
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: threads