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