title: After killing jar instance(kill <PID>) with shutdown hook process is not being killed
body: <p>I have a Java program with an attached shutdown hook. I run it and after I kill the running process with <code>kill &lt;PID&gt;</code>. By doing this the shutdown hook got executed and the related threads stopped immediately. But the process is still running in the background. So what could be the problem here?</p>
  
  <p>Process:</p>
  
  <ol>
  <li><p><code>javac InfiniteLoop.java</code></p></li>
  <li><p><code>java InfiniteLoop</code></p></li>
  <li><p>For PID, <code>jps -ml | grep 'InfiniteLoop'</code></p></li>
  <li><p>kill <code>&lt;PID&gt;</code></p></li>
  </ol>
  
  <pre><code>public class InfiniteLoop {
  
    static boolean isInfinte = true;
  
    public static void main(String[] args) throws InterruptedException {
  
      Thread myThread = new MyShutDownHook();
      Runtime.getRuntime().addShutdownHook(myThread);
      while (isInfinte) {
        Thread.sleep(3000);
        System.out.println("Loop is running");
      }
      System.out.println("Loop Exited");
      myThread.interrupt();
    }
  }
  
  class MyShutDownHook extends Thread {
  
    @Override
    public void run() {
  
      System.out.print("Got Kill Message so stopping application");
      InfiniteLoop.isInfinte = false;
      boolean currentLoopStatus = true;
  while (currentLoopStatus) {
        try {
          Thread.sleep(3000);
        } catch (InterruptedException e) {
          System.out.print("Got Intteruption");
          currentLoopStatus = false;        
          e.printStackTrace();
          System.exit(0);
        }
        System.out.println("Child Thread Running");
      }
    }
  }
  </code></pre>