class shutdown1 extends Thread
{
public void run()
{
System.out.println("Shut Down Hook Task Completed");
}
}
class shutdown2
{
public static void main(String surat[])
{
Runtime r=Runtime.getRuntime();
r.addShutdownHook(new shutdown1());
System.out.println("Now Main sleeping... press ctrl+c to exit");
try
{
Thread.sleep(5000);
}
catch(Exception e){}
}
}
Output:
{
public void run()
{
System.out.println("Shut Down Hook Task Completed");
}
}
class shutdown2
{
public static void main(String surat[])
{
Runtime r=Runtime.getRuntime();
r.addShutdownHook(new shutdown1());
System.out.println("Now Main sleeping... press ctrl+c to exit");
try
{
Thread.sleep(5000);
}
catch(Exception e){}
}
}
Output:
No comments:
Post a Comment