File tree Expand file tree Collapse file tree
src/main/java/api/java/lang Expand file tree Collapse file tree Original file line number Diff line number Diff line change 22
33public class ShutdownHookDemo {
44
5- // a class that extends thread is to be called when the program does exit
6- static class ShutDownHook extends Thread {
7- public void run () {
8- System .out .println ("This thread part of the class ShutDownHook is executed after the main thread exited..." );
9- }
10- }
11-
125 public static void main (String [] args ) throws InterruptedException {
136 System .out .println ("Demo of a Shutdown hook." );
147 Runtime .getRuntime ().addShutdownHook (new ShutDownHook ());
158 System .out .println ("Waiting 5 second..." );
169 Thread .sleep (5000 );
1710 System .out .println ("At the end of the main thread, the shutdownhook is executed" );
1811 }
12+
13+ // a class that extends thread is to be called when the program does exit
14+ static class ShutDownHook extends Thread {
15+ public void run () {
16+ System .out .println ("This thread, part of the class ShutDownHook, is executed after the main thread exited..." );
17+ }
18+ }
1919}
You can’t perform that action at this time.
0 commit comments