diff options
author | jfrijters <jfrijters> | 2012-12-18 10:08:29 +0400 |
---|---|---|
committer | jfrijters <jfrijters> | 2012-12-18 10:08:29 +0400 |
commit | d7517acd1a0eb4fc1605b217bf569c789d842731 (patch) | |
tree | 622edb6c54b9d1e72abd3d82f30dc5b85eb1be83 /openjdk/java | |
parent | ff1d0c0b13d2aec77d6279b9fd4e6b4cc8741ef6 (diff) |
Only register the AppDomain.ProcessExit event handler when necessary.
Diffstat (limited to 'openjdk/java')
-rw-r--r-- | openjdk/java/lang/Shutdown.java | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/openjdk/java/lang/Shutdown.java b/openjdk/java/lang/Shutdown.java index 69304a94..947f0e39 100644 --- a/openjdk/java/lang/Shutdown.java +++ b/openjdk/java/lang/Shutdown.java @@ -60,6 +60,9 @@ class Shutdown { // the index of the currently running shutdown hook to the hooks array private static int currentRunningHook = 0; + // [IKVM] have we registered the AppDomain.ProcessExit event handler? + private static boolean registeredProcessExit; + /* The preceding static fields are protected by this lock */ private static class Lock { }; private static Object lock = new Lock(); @@ -74,7 +77,7 @@ class Shutdown { } } - static { + private static void registerProcessExit() { try { // MONOBUG Mono doesn't support starting a new thread during ProcessExit // (and application shutdown hooks are based on threads) @@ -131,6 +134,11 @@ class Shutdown { throw new IllegalStateException("Shutdown in progress"); } + if (!registeredProcessExit) { + registeredProcessExit = true; + registerProcessExit(); + } + hooks[slot] = hook; } } |