Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
java: obey to sonar, use nio.file.delete for better error messages
[simgrid.git] / src / bindings / java / org / simgrid / msg / Process.java
index 18664ac..cfbc5da 100644 (file)
@@ -5,8 +5,8 @@
 
 package org.simgrid.msg;
 
-import java.util.Arrays;
 import java.util.ArrayList;
+import java.util.Arrays;
 
 /**
  * A process may be defined as a code, with some private data, executing
@@ -253,8 +253,8 @@ public abstract class Process implements Runnable {
        public native void migrate(Host host);  
        /**
         * Makes the current process sleep until millis milliseconds have elapsed.
-        * You should note that unlike "waitFor" which takes seconds, this method takes milliseconds.
-        * FIXME: Not optimal, maybe we should have two native functions.
+        * You should note that unlike "waitFor" which takes seconds (as usual in SimGrid), this method takes milliseconds (as usual for sleep() in Java).
+        * 
         * @param millis the length of time to sleep in milliseconds.
         */
        public static void sleep(long millis) throws HostFailureException  {
@@ -299,9 +299,7 @@ public abstract class Process implements Runnable {
                        Msg.info("Unexpected behavior. Stopping now");
                        System.exit(1);
                }
-               catch(ProcessKilledError pk) {
-                       /* The process was killed before its end. With a kill() or something. */
-               }       
+               /* Let the ProcessKilledError (that we'd get if the process is forcefully killed) flow back to the caller */
        }
 
        /**
@@ -331,4 +329,10 @@ public abstract class Process implements Runnable {
         */
        public static native int getCount();
 
+        public static void debugAllThreads() {
+           // Search remaining threads that are not main nor daemon
+            for (Thread t : Thread.getAllStackTraces().keySet())
+                if (! t.isDaemon() && !t.getName().equals("main"))
+                    System.err.println("Thread "+t.getName()+" is still running! Please report that bug");
+        }
 }