You can define and instantiate a thread in one of two ways:
■ Extend the java.lang.Thread class.
■ Implement the Runnable interface.
In both cases we have to override run() method.
How come when we extend class we combine both the thread and the job (the code in the run()method) into one class, and when we implement Runnable we've split it into two classes—the Thread class for the thread-specific code and your Runnable implementation class for your job-that-should-be-run-by-a-thread code.?
The Thread class should never have been declared to implement Runnable. It is a design flaw that we can extend Thread instead of implementing Runnable. Thread's job is to execute a task in its own thread of execution. Runnable's job is to be that task.
You've gotta fight it! Don't give in! Read this tiny ad: