What is the 2 way of creating a thread ? Which is the best way and why?

What is the 2 way of creating a thread ? Which is the best way and why?

Defining, Instantiating, and Starting new Threads
The code which we want to run as a thread of execution is written inside a run() method.
We can define a thread either by:
1. Extending a java.lang.Thread class
2. Implementing a java.lang.Runnable Interface.
 Runable is better than extending Thread.
it shares the same object to multiple threads.
 if you extends Thread, you can\'t extend another class

By:Sumit Tripathi
Date:2021-05-15 00:00:00

Post Your Answers


User Email:

User Name:
Answers:

Related Java Subjective Links

Java Subjective interview questions and answers for experienced and fresher