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: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to