avalon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From l...@apache.org
Subject cvs commit: avalon-excalibur/thread/src/java/org/apache/avalon/excalibur/thread/impl BasicThreadPool.java
Date Wed, 14 May 2003 06:24:44 GMT
leif        2003/05/13 23:24:44

  Modified:    thread/src/java/org/apache/avalon/excalibur/thread/impl
                        BasicThreadPool.java
  Log:
  Avoid an NPE in the event that the pool is disposed before all worker threads
  have had a chance to call releaseWorker.  Should the underlying pools be blocking
  on their call to dispose until all elements are released to the pool?
  
  Revision  Changes    Path
  1.16      +12 -1     avalon-excalibur/thread/src/java/org/apache/avalon/excalibur/thread/impl/BasicThreadPool.java
  
  Index: BasicThreadPool.java
  ===================================================================
  RCS file: /home/cvs/avalon-excalibur/thread/src/java/org/apache/avalon/excalibur/thread/impl/BasicThreadPool.java,v
  retrieving revision 1.15
  retrieving revision 1.16
  diff -u -r1.15 -r1.16
  --- BasicThreadPool.java	11 Apr 2003 13:52:36 -0000	1.15
  +++ BasicThreadPool.java	14 May 2003 06:24:44 -0000	1.16
  @@ -210,6 +210,17 @@
       protected void releaseWorker( final WorkerThread worker )
       {
           worker.clearInterruptFlag();
  -        m_pool.put( (SimpleWorkerThread)worker );
  +        
  +        // If the pool is disposed before the last worker has been released
  +        //  m_pool will be null.  This can be difficult to avoid as there
  +        //  is no way to query whether or not all workers have actually been
  +        //  released.  Underlying pool implementations should probably block
  +        //  on their dispose methods until all outstanding objects have been
  +        //  returned.
  +        Pool pool = m_pool;  // Be thread safe
  +        if ( pool != null )
  +        {
  +            pool.put( (SimpleWorkerThread)worker );
  +        }
       }
   }
  
  
  

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


Mime
View raw message