class InterRupt3 extends Thread
{
public void run()
{
try
{
Thread.sleep(500);
System.out.println("Work");
}
catch(InterruptedException e)
{
System.out.println("Exception handled "+e);
}
System.out.println("Thread is still running...");
}
public static void main(String surat[])
{
InterRupt3 t1=new InterRupt3();
t1.start();
t1.interrupt();
}
}
Output:
{
public void run()
{
try
{
Thread.sleep(500);
System.out.println("Work");
}
catch(InterruptedException e)
{
System.out.println("Exception handled "+e);
}
System.out.println("Thread is still running...");
}
public static void main(String surat[])
{
InterRupt3 t1=new InterRupt3();
t1.start();
t1.interrupt();
}
}
Output:
No comments:
Post a Comment