Creating Thread:
- java.lang package providing class and interface to create Thread.
- java.lang.Thread class
- java.lang.Runnable interface
- We can extends from Thread class or Implementing from Runnable interface.
- We need to override run() method to place the thread logic after thread class definition.
When we use Runnable interface?
- Extending from Thread is easy while creating Custom Thread.
- In Parent child relation, to make the child as thread, we must implement from Runnable interface.
- Java doesn’t support Multiple inheritance, hence it cannot extends from Parent class and Thread class at a time.