Properly emulate main thread exceptions terminating application even if other threads are running

git-svn-id: https://simple-build-tool.googlecode.com/svn/trunk@866 d89573ee-9141-11dd-94d4-bdf5e562f29c
This commit is contained in:
dmharrah 2009-07-16 13:31:46 +00:00
parent b6a693be44
commit da85255f8e
1 changed files with 7 additions and 1 deletions

View File

@ -30,7 +30,13 @@ object TrapExit
val originalThreads = allThreads
val code = new ExitCode
val customThreadGroup = new ExitThreadGroup(new ExitHandler(Thread.getDefaultUncaughtExceptionHandler, originalThreads, code, log))
val executionThread = new Thread(customThreadGroup, "run-main") { override def run() { execute } }
val executionThread =
new Thread(customThreadGroup, "run-main")
{
override def run(): Unit =
try { execute }
catch { case e => log.trace(e); System.exit(1) } // an exception in the main thread causes the whole program to terminate
}
val originalSecurityManager = System.getSecurityManager
try