• Post Reply Bookmark Topic Watch Topic
  • New Topic

Runnbale overides over Thread class ?  RSS feed

 
Prabhat Ranjan
Ranch Hand
Posts: 397
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In the below code i have implemented Runnable and extended the Thread.

Why it is not asked to implement run() method of Runnable Interface




this code is working fine..could anyone please help me out to basic logic behind this implementation.
 
Lester Burnham
Rancher
Posts: 1337
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The "implements Runnable" is redundant, because the Thread class already implements Runnable - which means all its subclasses do so, too. So this code does whatever the Thread class's run method does, and its javadocs tell you what that is.

you should read ExtendingThreadVsImplementingRunnable to learn why extending Thread is almost never what you want to do.
 
Prabhat Ranjan
Ranch Hand
Posts: 397
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks you are very correct !
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!