Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes   about thread and Runnable interface Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "  about thread and Runnable interface" Watch "  about thread and Runnable interface" New topic
Author

about thread and Runnable interface

sujit kanase
Greenhorn

Joined: May 26, 2005
Posts: 2
does Runnable implements Thread Class
and which is better to use thread or Runnable and why?
srikanth reddy
Ranch Hand

Joined: Jul 28, 2005
Posts: 252
sujit

Thread class implements the Runnable interface ...

As far as second question i dont think there is any problem in using either ..anyone is OK ....

thanks

srikanth


Thanks & Regards<br /> <br />-Srikanth
Sandeep Chhabra
Ranch Hand

Joined: Aug 28, 2005
Posts: 340
See if your class extends some other class...and you need introduce concurrency in your class then you might be tempted to implement the Runnable Interface.
Otherwise you always have the option to extend Thread Class.


Regards<br />Sandy<br />[SCJP 5.0 - 75%]<br />[SCWCD 1.4 - 85%]<br />------------------<br />Tiger, Tiger burning bright,<br />Like a geek who works all night,<br />What new-fangled bit or byte,<br />Could ease the hacker's weary plight?
Shweta Dhaneshwar
Greenhorn

Joined: May 02, 2005
Posts: 1
does Runnable implements Thread Class
and which is better to use thread or Runnable and why?


for you 1st question the ans is a class can implement a interface or can extend a class.An interface can extend an interface.So the Runnable interface does not implement Thread Class.

I think we should use Runnable interface coz if your class extends Thread class...then you cannot extend another class(multiple inheritance not allowed in java)
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: about thread and Runnable interface
 
Similar Threads
threads
Thread
Basic Model Layout, Doubts on LockManager
Java Threads
For an object to be a target for a Thread, that object must be of type: