Difference between Runnable interface & Thread class?Which one to use, though both seems to be same? As per my knowledge,runnable can be implemented in such a case that already it has some hierarchy

-Thanks in advance

this is the problem which i have encountered many times in case of making GUIs using swings or either making applets for which you have to extend JFrame or Applet.
since java dont support multiple inheritence, you cant extend Threads simultaneously with JFrame or Applet. in that case we have to implement Runnable for using multithreading.

Well, unless you have a specific reason to extend JFrame, don't extend that either. Google "composition".

Implement Runnable unless you have some specific reason for extending Thread.

Thanks masijade.Still,not clear about this.
Say,test is a class which doesn't hav any parents.In such a case,why should i go specifically for runnable implementation instead Thread inherit.Pls,let me explain,the advantage of using runnable.

Thanks masijade.Still,not clear about this.
Say,test is a class which doesn't hav any parents.In such a case,why should i go specifically for runnable implementation instead Thread inherit.Pls,let me explain,the advantage of using runnable.

If there isn't any behavior of Thread that you need to alter by subclassing, why would you extend Thread? That's what they are saying here. If you can't point to an advantage in your code to extend Thread then you most likely have no reason to.

Keep in mind though, Runnable cannot return a value nor throw exceptions. If you need that functionality, use Callable.

This question has already been answered. Start a new discussion instead.