cocoon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Berin Loritsch <blorit...@d-haven.org>
Subject Re: GroupBasedProfileManager
Date Thu, 05 Jan 2006 14:10:15 GMT
Carsten Ziegeler wrote:

>Ok, perhaps the code isn't that bad...now, both methods
>(getGlobalBaseDatas and getGlobalDatas) are synchronized, so only one
>thread can enter them and therefore only one thread can change the
>corresponding objects. At the end of the method, the map is returned and
>this return value is then used for the current user profile.
>So, if now another thread is entering the getGlobalBaseDatas method and
>overwriting the copletBaseDatas.objects value, the first user is not
>affected as he is working on his copy. At least this is how I think it
>should work. WDYT?
>  
>

Without looking at the code it sounds like what you have here is 
something like this:

getGlobalDatas()
{
    data = getGlobalBaseDatas()
    doSomethingWith( data )
    return data
}

If that is the case (i.e. getGlobalDatas always starts with a copy of 
the base datas), then only the getGlobalBaseDatas should be 
synchronized.  That avoids two different threads synchronizing on the 
same monitor because they are accessing different threads.  It keeps the 
length of holding the monitor at its minimum.


Mime
View raw message