my dog learned polymorphism
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 Make it so: Java DB Connections & Transactions this week in the JDBC forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Thread class constructor" Watch "Thread class constructor" New topic

Thread class constructor

Peter Swiss

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..

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

Joined: Mar 03, 2011
Posts: 23
Ok, thanks Suhrid!
I agree. Here's the link:
subject: Thread class constructor
It's not a secret anymore!