Return-Path: Delivered-To: apmail-avalon-cvs-archive@avalon.apache.org Received: (qmail 18129 invoked by uid 500); 11 Apr 2003 13:52:39 -0000 Mailing-List: contact cvs-help@avalon.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Subscribe: List-Help: List-Post: List-Id: "Avalon CVS List" Reply-To: "Avalon Developers List" Delivered-To: mailing list cvs@avalon.apache.org Received: (qmail 18105 invoked by uid 500); 11 Apr 2003 13:52:38 -0000 Received: (qmail 18101 invoked from network); 11 Apr 2003 13:52:38 -0000 Received: from icarus.apache.org (208.185.179.13) by daedalus.apache.org with SMTP; 11 Apr 2003 13:52:38 -0000 Received: (qmail 42554 invoked by uid 1152); 11 Apr 2003 13:52:37 -0000 Date: 11 Apr 2003 13:52:37 -0000 Message-ID: <20030411135237.42551.qmail@icarus.apache.org> From: bloritsch@apache.org To: avalon-excalibur-cvs@apache.org Subject: cvs commit: avalon-excalibur/thread/src/java/org/apache/excalibur/thread/impl WorkerThread.java X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N 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 alive 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