Not sure sure if I am doing this right. I need to make a new thread to write out message certain number of times. I think this works so far but not sure if its the best way of doing it. Then i need to display another message after thread has finished running. How do I do that ? Using isAlive() ? How do i implement that ?
public class MyThread extends Thread {
    public void run() {
        int i = 0;
        while (i < 10) {
            System.out.println("hi");
            i++;
        }
    }
    public static void main(String[] args) {
        String n = Thread.currentThread().getName();
        System.out.println(n);
        Thread t = new MyThread();
        t.start();
    }
}
 
     
     
     
    