diff options
author | jfrijters <jfrijters> | 2012-12-17 16:45:54 +0400 |
---|---|---|
committer | jfrijters <jfrijters> | 2012-12-17 16:45:54 +0400 |
commit | ff1d0c0b13d2aec77d6279b9fd4e6b4cc8741ef6 (patch) | |
tree | d3ff19d6fb8338ff97af05e32f104ba08b82a3b0 /openjdk/java | |
parent | 147910517dce2ffbfdfc86b5ed1ee812cb25f6c1 (diff) |
Bug fix. Don't deadlock AppDomain.ProcessExit event handler when the event gets called from another thread than the one initiating exit.
Diffstat (limited to 'openjdk/java')
-rw-r--r-- | openjdk/java/lang/Shutdown.java | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/openjdk/java/lang/Shutdown.java b/openjdk/java/lang/Shutdown.java index 494154db..69304a94 100644 --- a/openjdk/java/lang/Shutdown.java +++ b/openjdk/java/lang/Shutdown.java @@ -28,6 +28,7 @@ package java.lang; import cli.System.AppDomain; import cli.System.EventArgs; import cli.System.EventHandler; +import cli.System.Threading.Monitor; /** * Package-private utility class containing data structures and logic @@ -258,8 +259,17 @@ class Shutdown { break; } } - synchronized (Shutdown.class) { - sequence(); + // [IKVM] We don't block here, because we're being called + // from the AppDomain.ProcessExit event and we don't want to + // deadlock with the thread that called exit. + // Note that our JNI DestroyJavaVM implementation doesn't + // call this method. + if (Monitor.TryEnter(Shutdown.class)) { + try { + sequence(); + } finally { + Monitor.Exit(Shutdown.class); + } } } |