commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bay...@apache.org
Subject cvs commit: jakarta-commons-sandbox/threadpool/src/test/org/apache/commons/threadpool TestThreadPool.java
Date Fri, 27 Feb 2004 04:45:49 GMT
bayard      2004/02/26 20:45:49

  Modified:    threadpool/src/java/org/apache/commons/threadpool
                        DefaultThreadPool.java
               threadpool/src/test/org/apache/commons/threadpool
                        TestThreadPool.java
  Log:
  addedeadgroup handling based on a year old patch from Jim Birchfield
  
  Revision  Changes    Path
  1.6       +15 -2     jakarta-commons-sandbox/threadpool/src/java/org/apache/commons/threadpool/DefaultThreadPool.java
  
  Index: DefaultThreadPool.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/threadpool/src/java/org/apache/commons/threadpool/DefaultThreadPool.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- DefaultThreadPool.java	27 Feb 2004 03:50:20 -0000	1.5
  +++ DefaultThreadPool.java	27 Feb 2004 04:45:49 -0000	1.6
  @@ -27,6 +27,7 @@
       private MTQueue queue = new MTQueue();
       private boolean stopped = false;
       private final ThreadPoolMonitor monitor;
  +    private ThreadGroup threadGroup;
   
       public DefaultThreadPool(ThreadPoolMonitor monitor,
                    int numberOfThreads, int threadPriority) {
  @@ -57,19 +58,31 @@
       public DefaultThreadPool(int numberOfThreads, int threadPriority) {
           this(new CommonsLoggingThreadPoolMonitor(), numberOfThreads, threadPriority);
       }
  +
  +    public void setThreadGroup(ThreadGroup threadGroup) {
  +        this.threadGroup = threadGroup;
  +    }
       
       /** Start a new thread running */
       public Thread startThread() {
  -        Thread thread = new Thread( this );
  +        Thread thread = createThread();
           thread.start();
           return thread;
       }
   
       public Thread startThread(int priority) {
  -        Thread thread = new Thread( this );
  +        Thread thread = createThread();
           thread.setPriority(priority);
           thread.start();
           return thread;
  +    }
  +
  +    private Thread createThread() {
  +        if(this.threadGroup != null) {
  +            return new Thread(this.threadGroup, this);
  +        } else {
  +            return new Thread(this);
  +        }
       }
   
       public void stop() {
  
  
  
  1.5       +3 -1      jakarta-commons-sandbox/threadpool/src/test/org/apache/commons/threadpool/TestThreadPool.java
  
  Index: TestThreadPool.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/threadpool/src/test/org/apache/commons/threadpool/TestThreadPool.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- TestThreadPool.java	27 Feb 2004 03:45:58 -0000	1.4
  +++ TestThreadPool.java	27 Feb 2004 04:45:49 -0000	1.5
  @@ -63,6 +63,8 @@
        * Factory method to create a new thread pool implementation
        */
       protected ThreadPool createThreadPool() {
  -        return new DefaultThreadPool();
  +        DefaultThreadPool tpool = new DefaultThreadPool();
  +        tpool.setThreadGroup( new ThreadGroup("TestThreadPoolGroup") );
  +        return tpool;
       }
   }
  
  
  

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


Mime
View raw message