Update of /var/cvs/src/org/mmbase/util
In directory james.mmbase.org:/tmp/cvs-serv21760

Modified Files:
        ThreadPools.java 
Log Message:
Introduces also an mmbase 'scheduler' instance


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.10
retrieving revision 1.11
diff -u -b -r1.10 -r1.11
--- ThreadPools.java    21 Jun 2007 15:50:22 -0000      1.10
+++ ThreadPools.java    9 Jul 2008 17:01:51 -0000       1.11
@@ -17,7 +17,7 @@
  *
  * @since MMBase 1.8
  * @author Michiel Meewissen
- * @version $Id: ThreadPools.java,v 1.10 2007/06/21 15:50:22 nklasens Exp $
+ * @version $Id: ThreadPools.java,v 1.11 2008/07/09 17:01:51 michiel Exp $
  */
 public abstract class ThreadPools {
     private static final Logger log = 
Logging.getLoggerInstance(ThreadPools.class);
@@ -28,13 +28,8 @@
     public static final ExecutorService filterExecutor = 
Executors.newCachedThreadPool();
 
 
-    /**
-     * For jobs there are 'scheduled', and typically happen on larger 
time-scales.
-     */
-    public static final ExecutorService jobsExecutor = new 
ThreadPoolExecutor(2, 10, 5 * 60 , TimeUnit.SECONDS, new 
ArrayBlockingQueue<Runnable>(200), 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.
                          */
@@ -49,8 +44,25 @@
                 t.setDaemon(true);
                 return t;
             }
+
+    /**
+     * For jobs there are 'scheduled', and typically happen on larger 
time-scales.
+     */
+    public static final ExecutorService jobsExecutor = new 
ThreadPoolExecutor(2, 10, 5 * 60 , TimeUnit.SECONDS, new 
ArrayBlockingQueue<Runnable>(200), new ThreadFactory() {
+
+            public Thread newThread(Runnable r) {
+                return ThreadPools.newThread(r, "JOBTHREAD");
+            }
         });
 
+    /**
+     * @since MMBase-1.9
+     */
+    public static final ScheduledExecutorService scheduler = new 
ScheduledThreadPoolExecutor(2, new ThreadFactory() {
+            public Thread newThread(Runnable r) {
+                return ThreadPools.newThread(r, "SCHEDULERTHREAD");
+            }
+        });
 
 
     private static final UtilReader properties = new 
UtilReader("threadpools.xml", new Runnable() { public void run() { configure(); 
}});
_______________________________________________
Cvs mailing list
[email protected]
http://lists.mmbase.org/mailman/listinfo/cvs

Reply via email to