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
Go4Expert Member
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.