how many ways to create Thread and which one is good?
runnable interface ot Thread class?

Answer Posted / srinu

Two ways of creating Thread
1)By extending java.lang.Thread class
2)By implementing java.lang.Runnable interface
Here 2"nd way is good because by using interface we can
implement multiple inheritance in our class

Is This Answer Correct ?    7 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

When a thread is executing synchronized methods , then is it possible to execute other synchronized methods simultaneously by other threads?

787


What is the best definition for data?

714


What is the purpose of a parameter?

782


What is a container in a gui?

732


What is difference between final and immutable?

780


What does \ mean in regex?

840


Does java map allow duplicates?

658


What is a parameter in java?

732


What is the static method?

749


What purpose do the keywords final, finally, and finalize fulfill?

863


How listener identify that the event came from a particular object?

1711


How do you compare objects in java?

694


How do you remove duplicates from an array in java?

713


What are the rules for variable declaration?

693


Explain different forms of polymorphism?

863