--if u extends a Thread class,u have to override the run(),create the object of the thread class and then start the thread like t.start().
--if u implement the Runnable interface we have to override the run(),create the reference for the Runnable interface and then pass the runnable interface reference to the Thread constructor.So that our own run() will be called rather than the default run().In this we are dividing the thread and job of the thread. the code looks like this….
class FooRunnable implements Runnable {
public void run() {
for(int x =1; x < 6; x++) {
System.out.println("Runnable running");
}
}
}
public class TestThreads {
public static void main (String [] args) {
FooRunnable r = new FooRunnable();
Thread t = new Thread(r);
t.start();
}}
If you create a thread using the no-argument constructor, the thread will call its own run() method when it's time to start working. That's exactly what you want when you extend Thread, but when you use Runnable, you need to tell the new thread to use your run() method rather than its own. The Runnable you pass to the Thread constructor is called the target or the target Runnable.