jQuery in Action, 3rd edition
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
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.. 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

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