package com.aimtocode.multithreading;
class MyThread extends Thread{
public void run(){
System.out.println("My thread is in running state.");
}
}
class ThreadSleepDemo{
public static void main(String args[]){
MyThread obj=new MyThread();
obj.start();
while(obj.isAlive())
{
try
{
obj.sleep(10);
}
catch(InterruptedException e)
{
System.out.println(“Sleeping thread interrupted”);
}
System.out.println(“Thread-Sleep Demo Complete”);
}
}