donaldp 2002/07/10 03:42:12 Modified: src/java/org/apache/avalon/cornerstone/blocks/connection Connection.java Log: Potential fix for a threading bug. The problem occured when Thread1 [dispose() method] interrupted Thread2 [in run() method] and Thread2 managed to get to notifyAll() before Thread1 got to wait(). This could occur if Thread1 was interupted or Thread2 was already being "shutdown" when Thread1 did the interrupt. Synchronization was added to the "shutdown" portion of thread 2 and the "interrupt" portion of Thread 1 to hopefully alleviate this problem. Reported By: [EMAIL PROTECTED] Revision Changes Path 1.10 +11 -11 jakarta-avalon-cornerstone/src/java/org/apache/avalon/cornerstone/blocks/connection/Connection.java Index: Connection.java =================================================================== RCS file: /home/cvs/jakarta-avalon-cornerstone/src/java/org/apache/avalon/cornerstone/blocks/connection/Connection.java,v retrieving revision 1.9 retrieving revision 1.10 diff -u -r1.9 -r1.10 --- Connection.java 16 Mar 2002 00:18:33 -0000 1.9 +++ Connection.java 10 Jul 2002 10:42:12 -0000 1.10 @@ -142,16 +142,16 @@ public void dispose() throws Exception { - if( null != m_thread ) + synchronized( this ) { - m_thread.interrupt(); - m_thread = null; - //Can not join as threads are part of pool - //and will never finish - //m_thread.join(); - - synchronized( this ) + if( null != m_thread ) { + m_thread.interrupt(); + m_thread = null; + //Can not join as threads are part of pool + //and will never finish + //m_thread.join(); + wait( /*1000*/ ); } } @@ -185,11 +185,11 @@ getLogger().warn( "Error shutting down connection", ioe ); } - m_thread = null; - m_runners.remove( this ); - synchronized( this ) { + m_thread = null; + m_runners.remove( this ); + notifyAll(); } }
-- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>