[jboss-cvs] JBossAS SVN: r94314 - projects/jboss-jca/trunk/fungal/src/main/java/org/jboss/jca/fungal/impl.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Sun Oct 4 09:30:21 EDT 2009
Author: jesper.pedersen
Date: 2009-10-04 09:30:21 -0400 (Sun, 04 Oct 2009)
New Revision: 94314
Modified:
projects/jboss-jca/trunk/fungal/src/main/java/org/jboss/jca/fungal/impl/FungalThreadFactory.java
projects/jboss-jca/trunk/fungal/src/main/java/org/jboss/jca/fungal/impl/KernelImpl.java
Log:
Use ThreadPoolExecutor directly, and name threads
Modified: projects/jboss-jca/trunk/fungal/src/main/java/org/jboss/jca/fungal/impl/FungalThreadFactory.java
===================================================================
--- projects/jboss-jca/trunk/fungal/src/main/java/org/jboss/jca/fungal/impl/FungalThreadFactory.java 2009-10-04 10:39:11 UTC (rev 94313)
+++ projects/jboss-jca/trunk/fungal/src/main/java/org/jboss/jca/fungal/impl/FungalThreadFactory.java 2009-10-04 13:30:21 UTC (rev 94314)
@@ -23,6 +23,7 @@
package org.jboss.jca.fungal.impl;
import java.util.concurrent.ThreadFactory;
+import java.util.concurrent.atomic.AtomicInteger;
/**
* The thread factory for JBoss JCA/Fungal
@@ -33,6 +34,9 @@
/** The thread group */
private ThreadGroup tg;
+ /** Thread number */
+ private AtomicInteger threadNumber;
+
/**
* Constructor
* @param tg The thread group
@@ -40,6 +44,7 @@
public FungalThreadFactory(ThreadGroup tg)
{
this.tg = tg;
+ this.threadNumber = new AtomicInteger(1);
}
/**
@@ -49,6 +54,6 @@
*/
public Thread newThread(Runnable r)
{
- return new Thread(tg, r);
+ return new Thread(tg, r, "fungal-" + threadNumber.getAndIncrement());
}
}
Modified: projects/jboss-jca/trunk/fungal/src/main/java/org/jboss/jca/fungal/impl/KernelImpl.java
===================================================================
--- projects/jboss-jca/trunk/fungal/src/main/java/org/jboss/jca/fungal/impl/KernelImpl.java 2009-10-04 10:39:11 UTC (rev 94313)
+++ projects/jboss-jca/trunk/fungal/src/main/java/org/jboss/jca/fungal/impl/KernelImpl.java 2009-10-04 13:30:21 UTC (rev 94314)
@@ -39,11 +39,14 @@
import java.util.List;
import java.util.Map;
import java.util.Set;
+import java.util.concurrent.BlockingQueue;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
import java.util.concurrent.ExecutorService;
-import java.util.concurrent.Executors;
+import java.util.concurrent.SynchronousQueue;
import java.util.concurrent.ThreadFactory;
+import java.util.concurrent.ThreadPoolExecutor;
+import java.util.concurrent.TimeUnit;
import javax.management.MBeanServer;
import javax.management.MBeanServerFactory;
@@ -73,8 +76,8 @@
/** Bean dependants */
private ConcurrentMap<String, Set<String>> beanDependants = new ConcurrentHashMap<String, Set<String>>();
- /** Executor service */
- private ExecutorService executorService;
+ /** Kernel thread pool */
+ private ThreadPoolExecutor threadPoolExecutor;
/** The old class loader */
private ClassLoader oldClassLoader;
@@ -125,9 +128,17 @@
ThreadGroup tg = kernelConfiguration.getThreadGroup();
if (tg == null)
tg = new ThreadGroup("jboss");
+
+ BlockingQueue<Runnable> threadPoolQueue = new SynchronousQueue<Runnable>(true);
ThreadFactory tf = new FungalThreadFactory(tg);
- executorService = Executors.newCachedThreadPool(tf);
+ threadPoolExecutor = new ThreadPoolExecutor(1, Integer.MAX_VALUE,
+ 60, TimeUnit.SECONDS,
+ threadPoolQueue,
+ tf);
+
+ threadPoolExecutor.prestartAllCoreThreads();
+
File root = null;
if (kernelConfiguration.getHome() != null)
@@ -290,7 +301,7 @@
}
// Shutdown thread pool
- executorService.shutdown();
+ threadPoolExecutor.shutdown();
// Shutdown all deployments
List<Deployment> shutdownDeployments = new LinkedList<Deployment>(deployments);
@@ -407,7 +418,7 @@
*/
ExecutorService getExecutorService()
{
- return executorService;
+ return threadPoolExecutor;
}
/**
More information about the jboss-cvs-commits
mailing list