Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Merge branch 'master' of git+ssh://scm.gforge.inria.fr//gitroot/simgrid/simgrid
[simgrid.git] / src / bindings / java / org / simgrid / msg / Mutex.java
index 96dca06..d670f55 100644 (file)
@@ -8,28 +8,32 @@ package org.simgrid.msg;
 /** A mutex  implemented on top of SimGrid synchronization mechanisms. 
  * You can use it exactly the same way that you use the mutexes, 
  * but to handle the interactions between the processes within the simulation.   
- *
+ * 
+ * Don't mix simgrid synchronization with Java native one, or it will deadlock!
  */
 public class Mutex {
        private long bind; // The C object -- don't touch it
-       
+
        public Mutex() {
                init();
        }
+       @Override
        protected void finalize() {
-               exit();
+               try {
+                       nativeFinalize();
+               } catch (Throwable e) {
+                       e.printStackTrace();
+               }
        }
-       private native void exit();
+       private native void nativeFinalize();
        private native void init();
        public native void acquire();
        public native void release();
-       
-       /**
-        * Class initializer, to initialize various JNI stuff
-        */
+
+       /** Class initializer, to initialize various JNI stuff */
        public static native void nativeInit();
        static {
-               Msg.nativeInit();
+               org.simgrid.NativeLib.nativeInit();
                nativeInit();
        }       
 }