Question : Thread v/s Runnable

hi guys
What is difference between writing thread by extending java.lang.Thread  and by implementing java.lang.Runnable? When do i prefer one over other?

thanks

Answer : Thread v/s Runnable

>>can you elaborate a little please.

When you need something to run in another thread, you need to create one explicitly. You have two alternatives for your application code and those two alternatives are the subjects of your question. But using a Thread means you need to create a subclass of Thread, and since you have created that subclass, it means you can't extend anything else, which you often do want to do, since Java doesn't supported multiple inheritance. This is not a problem if you implement Runnable
Random Solutions  
 
programming4us programming4us