class P extends Thread { @Override public void run() { try { for (int i = 1; i <= 5; i++) { System.out.println("akhil"); Thread.sleep(1000); } } catch (InterruptedException e) { // Exception handling code (empty in this case) } } } class D { public static void main(String[] args) throws InterruptedException { P r = new P(); r.start(); // Starts the thread for (int i = 1; i <= 5; i++) { System.out.println("tanishq"); Thread.sleep(1000); } } }