I tried using sleep() method but there is not much change , i could find the output that i expected ,i.e as follows
IN the Main thread method
IN the My thread method
IN the My thread method
IN the My thread method
IN the My thread method
IN the My thread method
IN the My thread method
IN the My thread method
IN the My thread method
IN the My thread method
IN the My thread method
IN the My thread method
IN the Main thread method
IN the Main thread method
IN the Main thread method
IN the Main thread method
IN the Main thread method
IN the Main thread method
IN the Main thread method
IN the Main thread method
IN the Main thread method
IN the Main thread method
But the changes that i made in the code is only i added sleep() method in the main method i couldn add to run method if i do so i find the following error .
ThreadDemo.java:4: run() in Mythread cannot implement run() in java.lang.Runnable; overridden method does not throw java.lang.InterruptedException
public void run() throws InterruptedException
Can anyone help me out on how to use sleep method in the run() method