Author: mturk
Date: Tue Apr 19 08:11:15 2011
New Revision: 1094918

URL: http://svn.apache.org/viewvc?rev=1094918&view=rev
Log:
Separate Native shutdownHook into two classes

Added:
    
commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/NativeShutdownHook.java
   (with props)
Modified:
    
commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/Native.java

Modified: 
commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/Native.java
URL: 
http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/Native.java?rev=1094918&r1=1094917&r2=1094918&view=diff
==============================================================================
--- 
commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/Native.java
 (original)
+++ 
commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/Native.java
 Tue Apr 19 08:11:15 2011
@@ -22,7 +22,7 @@ package org.apache.commons.runtime;
  * @since Runtime 1.0
  *
  */
-public final class Native extends Thread
+public final class Native
 {
 
     private Native()
@@ -70,13 +70,13 @@ public final class Native extends Thread
             }
             if (initialized) {
                 // Install Shutdown Hook.
-                Runtime.getRuntime().addShutdownHook(new Native());
+                Runtime.getRuntime().addShutdownHook(new NativeShutdownHook());
             }
         }
         return initialized;
     }
     
-    public static void terminate()
+    public static synchronized void terminate()
     {
         if (initialized) {
             initialized = false;
@@ -84,8 +84,4 @@ public final class Native extends Thread
         }        
     }
 
-    public void run()
-    {
-        terminate();
-    }
 }

Added: 
commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/NativeShutdownHook.java
URL: 
http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/NativeShutdownHook.java?rev=1094918&view=auto
==============================================================================
--- 
commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/NativeShutdownHook.java
 (added)
+++ 
commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/NativeShutdownHook.java
 Tue Apr 19 08:11:15 2011
@@ -0,0 +1,34 @@
+/* Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.commons.runtime;
+
+/**
+ * Native shutdown hook class.
+ * Used from Native.initialize so that Native.terminate
+ * is called on JVM shutdown
+ */
+final class NativeShutdownHook extends Thread
+{
+    public NativeShutdownHook()
+    {
+
+    }
+    public void run()
+    {
+        Native.terminate();
+    }
+}

Propchange: 
commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/NativeShutdownHook.java
------------------------------------------------------------------------------
    svn:eol-style = native


Reply via email to