jackrabbit-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Martijn Hendriks" <marti...@gx.nl>
Subject RE: Synchronized methods in ItemManager
Date Fri, 14 Sep 2007 16:02:17 GMT
Hi Stefan,

Thanks for your reply, but I still don't understand. Without synchronization, cache entries
can only be overwritten when multiple threads have concurrent access, isn't it? It is not
clear to me where the second thread comes from.

Best wishes,

Martijn


-----Oorspronkelijk bericht-----
Van: Stefan Guggisberg [mailto:stefan.guggisberg@gmail.com]
Verzonden: vr 14-9-2007 17:47
Aan: dev@jackrabbit.apache.org
Onderwerp: Re: Synchronized methods in ItemManager
 
hi martijn,

On 9/14/07, Martijn Hendriks <martijnh@gx.nl> wrote:
> Hi all,
>
> The ItemManager has a small number of synchronized methods such as
> getItem(ItemId id), which is heavily used. I cannot figure out why these
> calls must be synchronized...can somebody give me an idea? Thanks!

the ItemManager maintains a cache of  NodeImpl/PropertyImpl instances.
#getItem(itemId) e.g. is synchronized in order to guarantee the cache
integrity. the following code fragment needs to be synchronized, otherwise
cache entries might get accidentally overwritten:

        // check cache
        ItemImpl item = retrieveItem(id);
        if (item == null) {
            ....
            // create instance of item
            item = createItemInstance(id);
        }

cheers
stefan

>
> Best wishes,
>
> Martijn
>
>
> --
>
> Martijn Hendriks
> <GX> creative online development B.V.
>
> t: 024 - 3888 261
> f: 024 - 3888 621
> e: martijnh@gx.nl
>
> Wijchenseweg 111
> 6538 SW Nijmegen
> http://www.gx.nl/
>


Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message