class ReverseThread implements Runnable
{
Thread t;
int no;
boolean running = true;
ReverseThread(int n)
{
t=new Thread(this);
t.start();
no = n;
}
public void run()
{
try{
while(running)
{
System.out.println("The reverse thread is executing no = " + no);
no--;
if(no == 0)
running = false;
t.sleep(200);
}
}catch(InterruptedException e){e.printStackTrace();}
}
}
class rev
{
public static void main(String ar[])
{
ReverseThread t1=new ReverseThread(20);
}
}
Post a Comment