diff options
-rw-r--r-- | plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/config/impl/Config.java | 4 | ||||
-rw-r--r-- | plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/concurrent/ThreadPool.java | 10 |
2 files changed, 9 insertions, 5 deletions
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/config/impl/Config.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/config/impl/Config.java index fa6c869e38..522a0892ac 100644 --- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/config/impl/Config.java +++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/config/impl/Config.java @@ -26,9 +26,7 @@ public abstract class Config implements IConfig { private static final long serialVersionUID = 1L; - private static final int MAXIMUM_POOL_SIZE = 1000; - - protected static ExecutorService executorService = ThreadPool.create("test", 20, MAXIMUM_POOL_SIZE, 10); + protected static ExecutorService executorService = ThreadPool.create("test", 10, 1000, 10); private String name; diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/concurrent/ThreadPool.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/concurrent/ThreadPool.java index 9b16746460..ff52458685 100644 --- a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/concurrent/ThreadPool.java +++ b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/concurrent/ThreadPool.java @@ -216,8 +216,11 @@ public class ThreadPool extends ThreadPoolExecutor implements RejectedExecutionH @Override public boolean offer(Runnable runnable) { - if (threadPool.getPoolSize() < threadPool.getMaximumPoolSize()) + int poolSize = threadPool.getPoolSize(); + if (poolSize < threadPool.getMaximumPoolSize() && poolSize == threadPool.getActiveCount()) { + // Do not enqueue the new runnable command if we can create a new worker thread and there's currently no idle + // thread. return false; } @@ -259,8 +262,11 @@ public class ThreadPool extends ThreadPoolExecutor implements RejectedExecutionH public boolean offer(Runnable r) { - if (threadPool.getPoolSize() < threadPool.getMaximumPoolSize()) + int poolSize = threadPool.getPoolSize(); + if (poolSize < threadPool.getMaximumPoolSize() && poolSize == threadPool.getActiveCount()) { + // Do not enqueue the new runnable command if we can create a new worker thread and there's currently no idle + // thread. return false; } |