costin      2002/07/02 12:57:49

  Modified:    util/java/org/apache/tomcat/util/threads ThreadPool.java
  Log:
  Allow customization of thread.setDaemon().
  
  Previous versions of TP set all the threads in non-daemon mode, but
  this can create restart problems in some cases. However non-daemon mode
  is usefull in some cases
  
  Revision  Changes    Path
  1.3       +19 -4     
jakarta-tomcat-connectors/util/java/org/apache/tomcat/util/threads/ThreadPool.java
  
  Index: ThreadPool.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-tomcat-connectors/util/java/org/apache/tomcat/util/threads/ThreadPool.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- ThreadPool.java   22 Apr 2002 18:55:56 -0000      1.2
  +++ ThreadPool.java   2 Jul 2002 19:57:49 -0000       1.3
  @@ -125,6 +125,9 @@
        */
       protected boolean stopThePool;
   
  +    /* Flag to control if the main thread is 'daemon' */
  +    protected boolean isDaemon=true;
  +    
       static int debug=0;
   
       /**
  @@ -176,6 +179,18 @@
           return maxSpareThreads;
       }
   
  +    /** The default is true - the created threads will be
  +     *  in daemon mode. If set to false, the control thread
  +     *  will not be daemon - and will keep the process alive.
  +     */
  +    public void setDaemon( boolean b ) {
  +        isDaemon=b;
  +    }
  +    
  +    public boolean getDaemon() {
  +        return isDaemon;
  +    }
  +    
       //
       // You may wonder what you see here ... basically I am trying
       // to maintain a stack of threads. This way locality in time
  @@ -395,7 +410,7 @@
               shouldTerminate = false;
               this.p = p;
               t = new Thread(this);
  -            t.setDaemon(true);
  +            t.setDaemon(p.getDaemon() );
            t.setName( "MonitorRunnable" );
               t.start();
           }
  
  
  

--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to