Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Thread class constructor

 
Peter Swiss
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 58
Eclipse IDE Java Ubuntu
  • Likes 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The Thread class itself implements Runnable. Hence, since C extends Thread, C also IS-A Runnable.
 
Peter Swiss
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ok, thanks Suhrid!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic