commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sebb <seb...@gmail.com>
Subject Re: [pool] Pool config vs. factory hierarchies.
Date Fri, 29 Oct 2010 16:48:37 GMT
On 29 October 2010 17:06, James Carman <james@carmanconsulting.com> wrote:
> On Fri, Oct 29, 2010 at 11:40 AM, sebb <sebbaz@gmail.com> wrote:
>>
>> If Config instances are immutable, then there is no need to synch.
>> access to their contents.
>> However, if the field which stores the Config instance is not final,
>> then all accesses to that need to be synch. - or the field could be
>> volatile.
>>
>> Once the code has obtained the config pointer safely, it can access
>> the final Config fields without synch. This would eliminate the need
>> for the locks, provided that the config instance was fetched at most
>> once per operation.
>>
>
> If the only place where that field can change is in the reconfigure()
> method, then you can use the read/write lock to handle your
> synchronization.

Yes, but the code will still need to use the read lock whenever it
reads the field to ensure changes are propagated correctly.
Both the writer and reader threads need to synch. on the same lock in
order for changes to be published safely.

Not sure using a read/write lock would gain anything over using
volatile - which has the advantage that one cannot bypass it.

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

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


Mime
View raw message