best way for implementing thread in java

khushboo652's Avatar
Banned
pls give me the answer which is the best way to implement thread in java runnable interface or inheritance and why?
0
shabbir's Avatar, Join Date: Jul 2004
Go4Expert Founder
What all ways you have tried and looking for best amont them?
0
virxen's Avatar, Join Date: Nov 2009
Pro contributor
http://www.go4expert.com/showthread.php?t=4202
0
dagdu's Avatar, Join Date: Feb 2012
Newbie Member
By implementing runnable interface is best way to implement.By implementing we can reuse that thread and we can extends any other useful class.
0
alia123's Avatar, Join Date: Jan 2016
Contributor
Hello,
There are two ways of implementing threading in Java

1) By extending java.lang.Thread class, or

2) By implementing java.lang.Runnable interface.

Read more:
http://javarevisited.blogspot.in/201...d-in-java.html
Check this site for examples.
0
RRT2010's Avatar, Join Date: Apr 2011
Light Poster
Also you can see if you require to Synchronize the threads. This may be needed if you have many threads running in parallel to avoid concurrency.
0
ifeeleducation's Avatar, Join Date: Mar 2016
Newbie Member
Use Class is the best way for implementing thread in java
0
shabbir's Avatar, Join Date: Jul 2004
Go4Expert Founder
Quote:
Originally Posted by ifeeleducation View Post
Use Class is the best way for implementing thread in java
On what basis you say it is the best?
0
theglobalassociates's Avatar, Join Date: Apr 2016
Newbie Member
1.Extending Thread Class
2.Implementing Runnable Class