avalon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From blorit...@apache.org
Subject cvs commit: avalon-excalibur/thread/src/java/org/apache/excalibur/thread/impl WorkerThread.java
Date Fri, 11 Apr 2003 13:52:37 GMT
bloritsch    2003/04/11 06:52:36

  Modified:    thread/src/java/org/apache/avalon/excalibur/thread/impl
                        BasicThreadPool.java
               thread/src/java/org/apache/excalibur/thread/impl
                        WorkerThread.java
  Log:
  ensure that the interrupted flag is reset in the proper thread
  
  Revision  Changes    Path
  1.15      +1 -0      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.14
  retrieving revision 1.15
  diff -u -r1.14 -r1.15
  --- BasicThreadPool.java	11 Apr 2003 06:00:29 -0000	1.14
  +++ BasicThreadPool.java	11 Apr 2003 13:52:36 -0000	1.15
  @@ -209,6 +209,7 @@
        */
       protected void releaseWorker( final WorkerThread worker )
       {
  +        worker.clearInterruptFlag();
           m_pool.put( (SimpleWorkerThread)worker );
       }
   }
  
  
  
  1.6       +26 -0     avalon-excalibur/thread/src/java/org/apache/excalibur/thread/impl/WorkerThread.java
  
  Index: WorkerThread.java
  ===================================================================
  RCS file: /home/cvs/avalon-excalibur/thread/src/java/org/apache/excalibur/thread/impl/WorkerThread.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- WorkerThread.java	13 Mar 2003 05:48:11 -0000	1.5
  +++ WorkerThread.java	11 Apr 2003 13:52:36 -0000	1.6
  @@ -77,6 +77,11 @@
        * True if this thread is alive and not scheduled for shutdown.
        */
       private boolean m_alive;
  +    
  +    /**
  +     * True if this thread needs to clear the interrupt flag
  +     */
  +    private boolean m_clearInterruptFlag;
   
       /**
        * The thread pool this thread is associated with.
  @@ -103,6 +108,7 @@
           setName( name );
           m_work = null;
           m_alive = true;
  +        m_clearInterruptFlag = false;
           m_pool = pool;
   
           setDaemon( false );
  @@ -128,6 +134,7 @@
               {
                   preExecute();
                   m_work.execute();
  +                if (m_clearInterruptFlag) clearInterruptFlag();
                   m_threadControl.finish( null );
               }
               catch( final ThreadDeath threadDeath )
  @@ -149,6 +156,7 @@
                   debug( "done." );
                   m_work = null;
                   m_threadControl = null;
  +                if (m_clearInterruptFlag) clearInterruptFlag();
                   postExecute();
               }
   
  @@ -169,6 +177,7 @@
       {
           if( m_alive )
           {
  +            if (m_clearInterruptFlag) clearInterruptFlag();
               m_pool.releaseWorker( this );
           }
       }
  @@ -187,11 +196,28 @@
        */
       protected void preExecute()
       {
  +        clearInterruptFlag();
           //TODO: Thread name setting should reuse the
           //ThreadContext code if ThreadContext used.
       }
   
       /**
  +	 * 
  +	 */
  +	public void clearInterruptFlag()
  +    {
  +		if (Thread.currentThread().equals(this))
  +        {
  +            Thread.interrupted();
  +            m_clearInterruptFlag = false;
  +        }
  +        else
  +        {
  +            m_clearInterruptFlag = true;
  +        }
  +	}
  +
  +	/**
        * Set the <tt>alive</tt> variable to false causing the worker to die.
        * If the worker is stalled and a timeout generated this call, this method
        * does not change the state of the worker (that must be destroyed in other
  
  
  

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


Mime
View raw message