File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Thread

 
Prashant Ameta
Greenhorn
Posts: 11
  • 0
  • Mark post as helpful
  • send pies
  • 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
 
Rob Spoor
Sheriff
Pie
Posts: 20396
47
Chrome Eclipse IDE Java Windows
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please SearchFirst. This question has been asked and answered several times before.
 
Nikhil Sagar
Ranch Hand
Posts: 216
Java Linux Tomcat Server
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Prashant, always write a meaningful name of Topic when you post.
 
Jeff Verdegan
Bartender
Posts: 6109
6
Android IntelliJ IDE Java
  • 0
  • Mark post as helpful
  • send pies
  • 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
Java Linux Tomcat Server
  • 0
  • Mark post as helpful
  • send pies
  • 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.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic