]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.utils.thread/src/org/simantics/utils/threads/ThreadUtils.java
Replace System.err and System.out with SLF4J Logging
[simantics/platform.git] / bundles / org.simantics.utils.thread / src / org / simantics / utils / threads / ThreadUtils.java
index e9a6fa4e3aaa63645e2889e4b0050e009d71545f..cd8d6027e4d7c54b56eaa56a3ef39b24ea4adcae 100644 (file)
@@ -38,6 +38,9 @@ import java.util.concurrent.TimeUnit;
 import java.util.concurrent.atomic.AtomicInteger;
 import java.util.concurrent.locks.Lock;
 
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
 /**
  * Utility for switching threads
  * 
@@ -46,6 +49,7 @@ import java.util.concurrent.locks.Lock;
  */
 public class ThreadUtils {
 
+    private static final Logger LOGGER = LoggerFactory.getLogger(ThreadUtils.class);
     public static final int CORES = Runtime.getRuntime().availableProcessors();
 
     /**
@@ -886,10 +890,10 @@ public class ThreadUtils {
             if (!pool.awaitTermination(timeoutMs, TimeUnit.MILLISECONDS)) {
                 List<Runnable> leftovers = pool.shutdownNow(); // Cancel currently executing tasks
                 if (!leftovers.isEmpty())
-                    System.err.println("Thread pool '" + pool.toString()  + "' contained " + leftovers.size() + " tasks at forced shutdown: " + leftovers);
+                    LOGGER.warn("Thread pool '" + pool.toString()  + "' contained " + leftovers.size() + " tasks at forced shutdown: " + leftovers);
                 // Wait a while for tasks to respond to being cancelled
                 if (!pool.awaitTermination(timeoutMs, TimeUnit.MILLISECONDS))
-                    System.err.println("Thread pool '" + pool.toString()  + "' did not terminate");
+                    LOGGER.warn("Thread pool '" + pool.toString()  + "' did not terminate");
             }
         } catch (InterruptedException ie) {
             // (Re-)Cancel if current thread also interrupted