Thread vs Runnable
Thread is a block of code which can execute concurrently with other threads in the JVM. You can create and run a thread in either ways; Extending Thread class, Implementing Runnable interface. Both approaches do the same job but there have been some differences. Almost everyone have this question in their minds: which one is best to use? We will see the answer at the end of this post. The most common difference is When you extends Thread class, after that you can’t extend any other class which you required. (As you know, Java does not allow inheriting more than one class). When you implements Runnable , you can save a space for your class to extend any other class in future or now. When you extends Thread class, each of your thread creates unique object and associate with it. When you implements Runnable , it shares the same object to multiple threads. 1)If you want to extend the Thread class then ...