thread in Java

Java thread can be created by 
* Extend the Thread class and override its run() method. The thread can be run by creating an instance of the class and then calling its start() method. 
* Implement the Runnable interface and override its run() method. The thread can be run by passing an instance of the class to a Thread object's constructor and then calling the its start() method.
```
class T1 extends Thread {
    public void run() {
        System.out.println("T1");
    }
}

class T2 implements Runnable {
    public void run() {
        System.out.println("T2");
    }
}

class Main {
    public static void main(String[] args) {
        T1 t1 = new T1();
        t1.start();
        Thread t2 = new Thread(new T2());
        t2.start();
    }
}
```