avalon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Niclas Hedhman <nic...@hedhman.org>
Subject Re: [RT] Notification pattern has interesting effects on IoC
Date Thu, 26 Feb 2004 16:30:44 GMT
On Friday 27 February 2004 00:20, Leo Sutic wrote:
> But don't you have to synchronize on a lock for m_Listeners when
> you traverse the list for sending notifications?

> Otherwise you can get:
>
>  public void addMyListener( MyListener listener )
>  {
>      synchronized( m_Listeners )
>      {
>          ArrayList clone = (ArrayList) m_Listeners.clone();
>          m_Listeners = clone;
>          clone.add( listener );
>      }
>  }

Hmmm... 

public void addMyListener( MyListener listener )
{
    ArrayList clone;
    synchronized( m_Listeners )
    {
        clone = (ArrayList) m_Listeners.clone();
        clone.add( listener );
    }
    m_Listeners = clone;
}

??

-- 
+---------//-------------------+
|   http://www.bali.ac         |
|  http://niclas.hedhman.org   |
+------//----------------------+

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


Mime
View raw message