Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

3
  • I don't know whether this is proper or not: extend Thread's run() { while(!isInterrupted()) { /* run your java codes here */ }}} Then, call interrupt() for the extended Thread class. Commented Jan 9, 2012 at 7:17
  • you cannot rely on shutdown hook.look at Java Monitoring and Management Commented Jan 9, 2012 at 7:44
  • @merlin: again merlin ,according to your question you want graceful ( clean up the resources and say bye bye and come out ) .if you want to detect abnormal termination , you need to handle outside JVM boundary i.e. at OS level. To detect whether your process launch java process inside a Perl script, but have the script wait for the JVM using the waitpid system call. Commented Jan 9, 2012 at 9:53