Update of /var/cvs/src/org/mmbase/util
In directory james.mmbase.org:/tmp/cvs-serv479
Modified Files:
Tag: MMBase-1_8
ThreadPools.java
Log Message:
ported the 'scheduler' from HEAD
See also: http://cvs.mmbase.org/viewcvs/src/org/mmbase/util
Index: ThreadPools.java
===================================================================
RCS file: /var/cvs/src/org/mmbase/util/ThreadPools.java,v
retrieving revision 1.5.2.1
retrieving revision 1.5.2.2
diff -u -b -r1.5.2.1 -r1.5.2.2
--- ThreadPools.java 28 Mar 2007 12:20:43 -0000 1.5.2.1
+++ ThreadPools.java 12 Aug 2008 13:05:18 -0000 1.5.2.2
@@ -15,24 +15,14 @@
*
* @since MMBase 1.8
* @author Michiel Meewissen
- * @version $Id: ThreadPools.java,v 1.5.2.1 2007/03/28 12:20:43 michiel Exp $
+ * @version $Id: ThreadPools.java,v 1.5.2.2 2008/08/12 13:05:18 michiel Exp $
*/
public abstract class ThreadPools {
private static final Logger log =
Logging.getLoggerInstance(ThreadPools.class);
- /**
- * Generic Thread Pools which can be used by 'filters'.
- */
- public static final Executor filterExecutor =
Executors.newCachedThreadPool();
-
- /**
- * For jobs there are 'scheduled', and typically happen on larger
time-scales.
- */
- public static final Executor jobsExecutor = new ThreadPoolExecutor(2, 10,
5, TimeUnit.MINUTES, new LinkedBlockingQueue(), new ThreadFactory() {
-
- public Thread newThread(Runnable r) {
- Thread t = new Thread(r, "JOBTHREAD") {
+ private static Thread newThread(Runnable r, String id) {
+ Thread t = new
Thread(org.mmbase.module.core.MMBaseContext.getThreadGroup(), r, id) {
/**
* Overrides run of Thread to catch and log all
exceptions. Otherwise they go through to app-server.
*/
@@ -47,6 +37,27 @@
t.setDaemon(true);
return t;
}
+
+ /**
+ * Generic Thread Pools which can be used by 'filters'.
+ */
+ public static final Executor filterExecutor =
Executors.newCachedThreadPool();
+
+
+ /**
+ * For jobs there are 'scheduled', and typically happen on larger
time-scales.
+ */
+ public static final Executor jobsExecutor = new ThreadPoolExecutor(2, 10,
5, TimeUnit.MINUTES, new LinkedBlockingQueue(), new ThreadFactory() {
+
+ public Thread newThread(Runnable r) {
+ return ThreadPools.newThread(r, "JOBTHREAD");
+ }
+ });
+
+ public static final ScheduledExecutorService scheduler = new
ScheduledThreadPoolExecutor(2, new ThreadFactory() {
+ public Thread newThread(Runnable r) {
+ return ThreadPools.newThread(r, "SCHEDULERTHREAD");
+ }
});
@@ -56,6 +67,7 @@
public static final void shutdown() {
((ExecutorService) filterExecutor).shutdown();
((ExecutorService) jobsExecutor).shutdown();
+ ((ExecutorService) scheduler).shutdown();
}
}
_______________________________________________
Cvs mailing list
[email protected]
http://lists.mmbase.org/mailman/listinfo/cvs