public class Main {
    public static void main(String[] args) {
        MyThread t1 = new MyThread(1);
        MyThread t2 = new MyThread(2);
       t1.start();
       t2.start();
       try {
           t1.join(500);
           System.out.println(t1.isAlive());
           t2.join(500);
           System.out.println(t2.isAlive());
       }
       catch (InterruptedException ie) {
           System.out.println(ie);
       }
    }
}
class MyThread extends Thread {
    int id;
    public MyThread(int _id) {
        id = _id;
    }
    @Override
    public void run() {

        for(int i = 0; i < 20; i++) {
            System.out.println("Thread " + id + " " + i);
            try {
                Thread.sleep(10);
            }
            catch (InterruptedException ie) {

            }
        }

    }
}