Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Correct way to exit an application  RSS feed

 
Chris Waguespack
Ranch Hand
Posts: 36
Eclipse IDE Flex Mac
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
After reading some other posts, I understand that using System.exit() is not the preferable way to exit an application, but instead I should use a RuntimeException (I think?). Could anyone provide some more information on this, and why System.exit() should not be used (both in cases where the application is told by the user to exit and when the application needs to terminate immediately).

Thanks,
Chris
 
Ulf Dittmer
Rancher
Posts: 42972
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'd consider using exceptions to be worse than using System.exit. A cleaner way would be to terminate explicitly (in a safe way) all non-daemon threads. That will terminate the JVM as well.
 
Manuel Kampert
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Where did you read about throwing runtime exceptions??

I can't beleave this to be the correct way. An application exit
is not an execptional thing to my understanding. An that is what
exceptions are for.

Regards,
Manuel
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!