You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@avalon.apache.org by bl...@apache.org on 2004/05/05 23:44:29 UTC

cvs commit: avalon-excalibur/event/impl/src/java/org/apache/excalibur/event/command TPCThreadManager.java

bloritsch    2004/05/05 14:44:29

  Modified:    event/impl project.xml
               event/impl/src/java/org/apache/excalibur/event/command
                        TPCThreadManager.java
  Log:
  make threads run in background, as deamon threads
  
  Revision  Changes    Path
  1.10      +1 -7      avalon-excalibur/event/impl/project.xml
  
  Index: project.xml
  ===================================================================
  RCS file: /home/cvs/avalon-excalibur/event/impl/project.xml,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- project.xml	2 Apr 2004 05:53:14 -0000	1.9
  +++ project.xml	5 May 2004 21:44:29 -0000	1.10
  @@ -44,12 +44,6 @@
               <id>commons-collections</id>
               <version>2.1</version>
           </dependency>
  -        
  -        <dependency>
  -            <groupId>excalibur-instrument</groupId>
  -            <artifactId>excalibur-instrument</artifactId>
  -            <version>1.2</version>
  -        </dependency>
           <dependency>
               <groupId>excalibur-pool</groupId>
               <artifactId>excalibur-pool-api</artifactId>
  @@ -63,7 +57,7 @@
           <dependency>
               <groupId>concurrent</groupId>
               <artifactId>concurrent</artifactId>
  -            <version>1.3.1</version>
  +            <version>1.3.3</version>
           </dependency>
   
           <dependency>
  
  
  
  1.5       +12 -1     avalon-excalibur/event/impl/src/java/org/apache/excalibur/event/command/TPCThreadManager.java
  
  Index: TPCThreadManager.java
  ===================================================================
  RCS file: /home/cvs/avalon-excalibur/event/impl/src/java/org/apache/excalibur/event/command/TPCThreadManager.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- TPCThreadManager.java	28 Feb 2004 11:47:26 -0000	1.4
  +++ TPCThreadManager.java	5 May 2004 21:44:29 -0000	1.5
  @@ -23,6 +23,7 @@
   import org.apache.excalibur.util.SystemUtil;
   
   import EDU.oswego.cs.dl.util.concurrent.PooledExecutor;
  +import EDU.oswego.cs.dl.util.concurrent.ThreadFactory;
   
   /**
    * This is a ThreadManager that uses a certain number of threads per
  @@ -104,11 +105,21 @@
               throw new IllegalStateException( "ThreadManager is already initailized" );
           }
   
  -        final int maxPoolSize = ( m_processors * m_threadsPerProcessor ) + 1;
  +        final int maxPoolSize = Math.max(( m_processors * m_threadsPerProcessor ) + 1, m_processors + 1);
           m_threadPool = new PooledExecutor( m_processors + 1 );
           m_threadPool.setMinimumPoolSize( 2 ); // at least two threads
           m_threadPool.setMaximumPoolSize( maxPoolSize );
           m_threadPool.waitWhenBlocked();
  +        m_threadPool.setThreadFactory( new ThreadFactory() {
  +            public Thread newThread(Runnable run) {
  +                Thread newThread = new Thread(run);
  +
  +                newThread.setDaemon( true );
  +                newThread.setPriority( Thread.MIN_PRIORITY );
  +
  +                return newThread;
  +            }
  +        });
           if( maxPoolSize == 2 )
           {
               // The PooledExecutor has an inherent race condition between releasing threads
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: cvs-unsubscribe@avalon.apache.org
For additional commands, e-mail: cvs-help@avalon.apache.org