As you can see Thread implements Runnable. You are going to need to override run(), and you use run() when you implement Runnable, so no difference there. You can even call the non-static methods of Thread if you need to inside your Runnable, but you need to call Thread.currentThread(), so you aren't losing any functionality by not using the Runnalbe interface instead.
extend Thread and you are stuck, you can't extend another class if you need it. So just implement Runnable. Starting the thread is also slightly different.
[ August 16, 2006: Message edited by: Rusty Shackleford ] [ August 16, 2006: Message edited by: Rusty Shackleford ]
"Computer science is no more about computers than astronomy is about telescopes" - Edsger Dijkstra
The soul is dyed the color of its thoughts. Think only on those things that are in line with your principles and can bear the light of day. The content of your character is your choice. Day by day, what you do is who you become. Your integrity is your destiny - it is the light that guides your way. - Heraclitus
1) Interface Runnable have only 1 method which you mandatory to implement.
2) If you need other methods like suspend() resume() sleep() join() yield() and stop() then
go for extending class Thread
3) Extending the Thread class will make your class unable to extend other classes, because of the single inheritence feature in JAVA.
4) If you want to execute run() method for multiple no of times then its better to you Runnable.
Thread class & runnable interface are the same.the difference is just that of a class and an interface and usage depends on design decision.
Objects of class implementing runnable don't act as threads. they have to b given to Thread objects which actually spawn a new thread.
for general usage we put the required code block in a Runnable implementing class. Now this becomes service which needs to b executed. its object is then given to actual Thread object to create a thread and run this service.
Extend thread only when you want to add functionality to Thread class