wood burning stoves 2.0*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Thread class constructor Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Thread class constructor" Watch "Thread class constructor" New topic
Author

Thread class constructor

Peter Swiss
Greenhorn

Joined: Mar 03, 2011
Posts: 23
Hi guys,

This piece of code compiles fine



Class C does not implement Runnable. Still, object of C is passed to the Thread constructor.
Here is the API for Thread class.. http://download.oracle.com/javase/6/docs/api/java/lang/Thread.html

The constructors are no-arg, with a Runnable or with a String. How come this code compiles, when class C is not a Runnable nor a String?
Suhrid Karthik
Ranch Hand

Joined: Aug 31, 2008
Posts: 58

The Thread class itself implements Runnable. Hence, since C extends Thread, C also IS-A Runnable.
Peter Swiss
Greenhorn

Joined: Mar 03, 2011
Posts: 23
Ok, thanks Suhrid!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Thread class constructor
 
Similar Threads
For an object to be a target for a Thread, that object must be of type:
parameters for Thread constructor (Q46 from Boone�s exam)
starting a thread in a constructor
Thread tricky questions.
Adding JScrollPane to JPanel?