You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by co...@apache.org on 2005/11/26 06:41:45 UTC

svn commit: r349084 - in /tomcat/sandbox/java/org/apache/tomcat/util/threads: ThreadPool.java ThreadPoolRunnable.java ThreadWithAttributes.java

Author: costin
Date: Fri Nov 25 21:41:43 2005
New Revision: 349084

URL: http://svn.apache.org/viewcvs?rev=349084&view=rev
Log:
A small change to allow access to the 'param' field in
ThreadWithAttributes. This allows passing a param to the thread - like a
socket for example

Modified:
    tomcat/sandbox/java/org/apache/tomcat/util/threads/ThreadPool.java
    tomcat/sandbox/java/org/apache/tomcat/util/threads/ThreadPoolRunnable.java
    tomcat/sandbox/java/org/apache/tomcat/util/threads/ThreadWithAttributes.java

Modified: tomcat/sandbox/java/org/apache/tomcat/util/threads/ThreadPool.java
URL: http://svn.apache.org/viewcvs/tomcat/sandbox/java/org/apache/tomcat/util/threads/ThreadPool.java?rev=349084&r1=349083&r2=349084&view=diff
==============================================================================
--- tomcat/sandbox/java/org/apache/tomcat/util/threads/ThreadPool.java (original)
+++ tomcat/sandbox/java/org/apache/tomcat/util/threads/ThreadPool.java Fri Nov 25 21:41:43 2005
@@ -301,14 +301,15 @@
      * Executes a given Runnable on a thread in the pool, block if needed.
      */
     public void runIt(ThreadPoolRunnable r) {
-        if(null == r) {
-            throw new NullPointerException();
-        }
-
         ControlRunnable c = findControlRunnable();
         c.runIt(r);
     }
 
+    public void runIt(ThreadPoolRunnable r, Object param) {
+        ControlRunnable c = findControlRunnable();
+        c.runIt(r, param);
+    }
+
     private ControlRunnable findControlRunnable() {
         ControlRunnable c=null;
 
@@ -728,6 +729,11 @@
                 p.removeThread(Thread.currentThread());
             }
         }
+
+        public synchronized void runIt(ThreadPoolRunnable toRun) {
+            runIt( toRun, null);
+        }
+        
         /** Run a task
          *
          * @param toRun
@@ -746,13 +752,11 @@
          *
          * @param toRun
          */
-        public synchronized void runIt(ThreadPoolRunnable toRun) {
+        public synchronized void runIt(ThreadPoolRunnable toRun, 
+                Object param) {
 	    this.toRun = toRun;
-	    // Do not re-init, the whole idea is to run init only once per
-	    // thread - the pool is supposed to run a single task, that is
-	    // initialized once.
-            // noThData = true;
             shouldRun = true;
+            t.setParam(p, param);
             this.notify();
         }
 

Modified: tomcat/sandbox/java/org/apache/tomcat/util/threads/ThreadPoolRunnable.java
URL: http://svn.apache.org/viewcvs/tomcat/sandbox/java/org/apache/tomcat/util/threads/ThreadPoolRunnable.java?rev=349084&r1=349083&r2=349084&view=diff
==============================================================================
--- tomcat/sandbox/java/org/apache/tomcat/util/threads/ThreadPoolRunnable.java (original)
+++ tomcat/sandbox/java/org/apache/tomcat/util/threads/ThreadPoolRunnable.java Fri Nov 25 21:41:43 2005
@@ -18,6 +18,7 @@
 
 
 /** Implemented if you want to run a piece of code inside a thread pool.
+ *  You can also use Runnable + ThreadLocal or ThreadWithAttributes.
  */
 public interface ThreadPoolRunnable {
     // XXX use notes or a hashtable-like

Modified: tomcat/sandbox/java/org/apache/tomcat/util/threads/ThreadWithAttributes.java
URL: http://svn.apache.org/viewcvs/tomcat/sandbox/java/org/apache/tomcat/util/threads/ThreadWithAttributes.java?rev=349084&r1=349083&r2=349084&view=diff
==============================================================================
--- tomcat/sandbox/java/org/apache/tomcat/util/threads/ThreadWithAttributes.java (original)
+++ tomcat/sandbox/java/org/apache/tomcat/util/threads/ThreadWithAttributes.java Fri Nov 25 21:41:43 2005
@@ -27,7 +27,8 @@
  * JDK < 1.4 ).
  *
  * The main use is to store 'state' for monitoring ( like "processing
- * request 'GET /' ").
+ * request 'GET /' "), and to simplify information passing between threads.
+ * 
  */
 public class ThreadWithAttributes extends Thread {
     



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org