Thread Suicide on Shutdown?

Posted by yar on Stack Overflow See other posts from Stack Overflow or by yar
Published on 2010-05-06T13:04:52Z Indexed on 2010/05/06 13:08 UTC
Read the original article Hit count: 158

Filed under:
|

I have a java.util.Timer running at a fixed interval. I have added a Runtime#addShutdownHook and it shuts down when the VM ends normally or abnormally. However, it keeps the VM alive when a main terminates, unless I insist by doing a System.exit in the main. Is there any way for me to check if I'm the last Thread standing, or some other way to avoid altering a main that would exit normally on finish?

Note: I know a lot of people believe that java.util.Timer is deprecated (it's not), but unless your alternative helps me solve this problem...

© Stack Overflow or respective owner

Related posts about java

Related posts about thread