hi ,friend As you kbnow that java does not support multiple inheritance so that when you can write coding for applet then you extends the applet class ,in such a case you can't extends the Thread.so that to avoid this kinds of problem you have to implements the Runnable. I think this is sufficient for your understanding. Thanks . if i am wrong then mail me. firstname.lastname@example.org Bye.
Joined: Sep 19, 2000
Landon, The only good reason to derive a subclass from Thread is to extend its behavior - just like any other class. It's usually a better idea to implement Runnable. Delegation, when it satisfies the requirements, is a more flexible solution than specialization. While it's true that overriding run() is in some sense extending Thread's behavior, it's more in keeping with good OO practice to derive a Thread subclass only if you need to modify some more basic aspect. In the simple example programs you see in most books (where the author often just makes the main class a subclass of Thread), the two approaches are equivalent. In larger programs, this kind of failure to make the code reflect the design abstractions often leads to trouble. Just my opinion, of course. Jerry