Explain different ways of creating a thread. Which one would you prefer and why?



Explain different ways of creating a thread. Which one would you prefer and why?..

Answer / Nikhil Nailwal

There are several ways to create a thread in Java: extending Thread class or implementing Runnable interface. Extending the Thread class is more straightforward but can lead to issues with inheritance, while implementing the Runnable interface provides better control and is preferred when dealing with multiple threads.

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More Core Java Interview Questions

What is flush buffer?

1 Answers  


Does garbage collection occur in permanent generation space in jvm?

1 Answers  


How do you write a good declaration?

1 Answers  


Explain in detail about encapsulation with an example?

4 Answers  


How to overcome the exception object reference not set to an instance of object?

1 Answers   Wipro,


Can we rethrow the same exception from catch handler?

1 Answers  


How do you create immutable object in java?

1 Answers  


what is the need of the Ajax?

5 Answers   iFlex,


What does the string method compareto () do?

1 Answers  


When wait(), notify(), notifyall() methods are called does it releases the lock or holds the acquired lock?

1 Answers  


Explain about instanceof operator in java?

1 Answers  


What happens when main () method is declared as private?

1 Answers   Tech Mahindra,


Categories