What can cause Java to keep running after System.exit()?

The parent process has one thread dedicated to consuming each of the child's STDOUT and STDERR (which passes that output through to a log file). So far as I can see, those are working properly, since we're seeing all the output we expect to see in the log

i had a similar problem with my program not disappearing from task mgr when i was consuming the stdout/stderr. in my case, if I closed the stream that was listening before calling system.exit() then the javaw.exe hung around. strange, it wasn't writing to the stream...

the solution in my case was to simply flush the stream rather than close it before existing. of course, you could always flush and then redirect back to stdout and stderr before exit.


This can happen if your code (or a library you use) has a shutdown hook or a finalizer that doesn't finish cleanly.

A more vigorous (so should only be used in extreme cases!) way to force shutdown is by running:

Runtime.getRuntime().halt(0);