• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
  • Paul Clapham
  • Liutauras Vilda
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

Thread

 
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hii,I have a question Regarding threads
There are two ways to create a thread-
1.)by Extending the Thread class
2.)by implementing Runnable interface
which one is better and how would one decide???

Thanks in advance
 
Sheriff
Posts: 22822
132
Eclipse IDE Spring Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Please SearchFirst. This question has been asked and answered several times before.
 
Ranch Hand
Posts: 216
Tomcat Server Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Prashant, always write a meaningful name of Topic when you post.
 
Bartender
Posts: 6109
6
Android IntelliJ IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The answer to this question doesn't have much to do with multithreading. It's more about inheritance and class design in general.
 
Nikhil Sagar
Ranch Hand
Posts: 216
Tomcat Server Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Prashant Ameta wrote:Hii,I have a question Regarding threads
There are two ways to create a thread-
1.)by Extending the Thread class
2.)by implementing Runnable interface
which one is better and how would one decide???

Thanks in advance



Answers-
1.)When do you extend a class ??
2.)When do you implement an interface ??

as Jeff Verdegan have already told you that this question is more about inheritance and class design.
Then If you can answer these question then you can answer your own questions too.
If you can't answer these then you should study more about inheritance first before start Thread.
 
reply
    Bookmark Topic Watch Topic
  • New Topic