Create thread using java.lang.Runnable



class MyRunnable implements Runnable {
 @Override
 public void run() {
  System.out.println("\nBegin Work");
  try {
   System.out.println("Thread is working...");
  } catch (Exception e) {
   System.out.println("Error while running thread. Reason: "
     + e.getMessage());
  }
  System.out.println("Work Finished");
 }
}

public class RunnableFlight {
 public static void main(String[] array) {
  Thread myRunnable = new Thread(new MyRunnable());
  System.out.println("Name: " + myRunnable.getName());
  System.out.println("Priority: " + myRunnable.getPriority());
  System.out.println("State: " + myRunnable.getState());
  System.out.println("Id: " + myRunnable.getId());
  myRunnable.start();
 }
}
Output 
Name: Thread-0
Priority: 5
State: NEW
Id: 8

Begin Work
Thread is working...
Work Finished
To create a thread using java.lang.Runnable interface. A class required to implement Runnable interface. Then create an object of the implementer class and pass that object in the thread class object. Creating thread using Runnable interface has advantages.You could extends other class in the same implementer class.Your implementer class will not have unnecessary overhead of members which are available in the Thread class. So, its a good practice to create a thread using Runnable interface.