commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Janek Bogucki <jane...@yahoo.co.uk>
Subject SequencedHashMap: This class is thread-safe (was Re: Silly Question)
Date Thu, 24 Jan 2002 22:28:29 GMT
Hi John,

 --- John McNally <jmcnally@collab.net> wrote: > > 
> Remove the "This class is thread-safe" declaration
> in SequencedHashMap.

When I first read this class through I thought I'd
spotted a race condition in freshenSequence but a
rethink convinced me it was not thread-unsafe. Am I
wrong here? If not, what's the actual location of the
non thread-safe behaviour?

-Janek

    /**
     * Freshens the sequence of the element
<code>value</code> if
     * <code>value</code> is not <code>null</code>.
     *
     * @param key   The key whose sequence to freshen.
     * @param value The value whose existance to check
before removing the old
     *              key sequence.
     */
    protected void freshenSequence(Object key, Object
value)
    {
        if (value != null)
        {
            // Freshening existing element's sequence.
            keySequence.remove(key);
        }
        keySequence.add(key);
    }

__________________________________________________
Do You Yahoo!?
Everything you'll ever need on one web page
from News and Sport to Email and Music Charts
http://uk.my.yahoo.com

--
To unsubscribe, e-mail:   <mailto:commons-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:commons-dev-help@jakarta.apache.org>


Mime
View raw message