Create a thread that prints ” Hello from Thread” five times using the Thread class

Create a thread that prints ” Hello from Thread” five times using the Thread class

// Create a class that extends Thread
class MyThread extends Thread {
public void run() {
for (int i = 1; i <= 5; i++) {
System.out.println(“Hello from Thread”);
}
}
}

// Main class
public class ThreadExample {
public static void main(String[] args) {
// Create thread object
MyThread t = new MyThread();

    // Start the thread
    t.start();
}

}