X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=blobdiff_plain;f=bundles%2Forg.simantics.utils.thread%2Fsrc%2Forg%2Fsimantics%2Futils%2Fthreads%2FThreadUtils.java;h=15e818416bbd0d044ddcd05c115f21019409b88b;hb=refs%2Fchanges%2F65%2F1865%2F2;hp=e9a6fa4e3aaa63645e2889e4b0050e009d71545f;hpb=0ae2b770234dfc3cbb18bd38f324125cf0faca07;p=simantics%2Fplatform.git diff --git a/bundles/org.simantics.utils.thread/src/org/simantics/utils/threads/ThreadUtils.java b/bundles/org.simantics.utils.thread/src/org/simantics/utils/threads/ThreadUtils.java index e9a6fa4e3..15e818416 100644 --- a/bundles/org.simantics.utils.thread/src/org/simantics/utils/threads/ThreadUtils.java +++ b/bundles/org.simantics.utils.thread/src/org/simantics/utils/threads/ThreadUtils.java @@ -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(); /** @@ -878,7 +882,7 @@ public class ThreadUtils { * * @param pool {@link ExecutorService} to shut down */ - private static void shutdownAndAwaitTermination(ExecutorService pool, long timeoutMs) { + static void shutdownAndAwaitTermination(ExecutorService pool, long timeoutMs) { //long t = System.currentTimeMillis(); pool.shutdown(); // Disable new tasks from being submitted try { @@ -886,10 +890,10 @@ public class ThreadUtils { if (!pool.awaitTermination(timeoutMs, TimeUnit.MILLISECONDS)) { List 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