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

Why multiple inheritance is not supported by java?

755


What is :: operator in java?

723


Why arraylist is used in java?

779


What are the important methods of java exception class?

765


What is a class in java?

803


What is the difference between compare and compareto in java?

727


Can string be considered as a keyword?

806


What are the ways in which a thread can enter the waiting state?

726


Can we use synchronized block for primitives?

843


What are the advantages and disadvantages of reference counting in garbage collection?

785


Explain different ways of creating a thread?

780


Why do we need data serialization?

752


Is 0 an even number?

762


How strings are created in java?

817


What are the differences between checked exception and unchecked exception?

759