My main thread created a new thread
And when the new thread call System.exit(-1)
,my main thread be closed.
How can I handle the exit code and keep the main thread alive?
PS.
the new thread will call some method in other .jar
file, so I can't modify it.
You can't.
Terminates the currently running Java Virtual Machine. The argument serves as a status code; by convention, a nonzero status code indicates abnormal termination.
That's the javadoc.
So the method will terminate the entire JVM. Not just the thread....
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With