Win a copy of Svelte and Sapper in Action this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
Bartenders:
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

extend or implement?

 
Ranch Hand
Posts: 92
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
we can create thread by extending Thread class or implementing Runnable interface...

as far as my knowledge goes implementing is a better option for following 2 reasons:
(1) by implementing i have option of extending another class
(2) by extending the entire Thread class i would have the overhead of all properties of Thread class...which in some cases is not required.

so my question is while creating a thread which is the best and effecient way to create it and why?

help appreciated

cheers
amal
 
Ranch Hand
Posts: 280
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Extending Thread really means that you're creating a more specialized class of Thread - to do more than what Thread does, if you look at it from an OO perspective.
If that is not your goal, implementing is the way to go.
 
Forget Steve. Look at this tiny ad:
the value of filler advertising in 2020
https://coderanch.com/t/730886/filler-advertising
    Bookmark Topic Watch Topic
  • New Topic