Hello,

I can see that commit 67622ed2c8ae 
<https://github.com/orientechnologies/orientdb/commit/67622ed2c8aeeb6737629afd592b8659039123d0#diff-302836c4070ff340d9386cb26b1ad216R22>
 changed 
the logic to synchronized(this) instead of synchronized(lock) or the older 
synchronized(pools). Nevertheless, I still cannot see the volatile modifier 
being applied, even in the most recent revision of the file 
<https://github.com/orientechnologies/orientdb/blob/0b5fe336c9d5ca600d07d9222ab4be5f98f773cb/core/src/main/java/com/orientechnologies/orient/core/db/ODatabasePoolBase.java>
 (as 
of the time of writing). Is this safe?


Best regards,

Hosam Aly


On Tuesday, October 5, 2010 12:23:46 PM UTC+2, Lvc@ wrote:
>
> Good catch. Fixed in SVN 1540.
>
> Thanks!
>
> bye,
> Lvc@
>
> On 5 October 2010 12:10, Ignacio <[email protected] <javascript:>> wrote:
>
>> From what I've read, double-checked locking in Java is only thread-
>> safe if you use the volatile keyword when declaring singleton
>> variables. In classes like ODatabaseObjectPool, for example, volatile
>> isn't being used:
>>
>> private static ODatabaseObjectPool      globalInstance  = new
>> ODatabaseObjectPool();
>>
>> I also found an instance where double-checked locking is being applied
>> to a local variable, which is never going to work as intended, this is
>> in the ODatabasePoolAbstract.acquire() method:
>>
>>                OResourcePool<String, DB> pool = pools.get(name);
>>
>>                if (pool == null) {
>>
>>                        synchronized (pools) {
>>
>>                                if (pool == null) {
>>
>>                                        pool = new OResourcePool<String, 
>> DB>(maxSize, this);
>>
>>                                        pools.put(name, pool);
>>
>>                                }
>>
>>                        }
>>
>>                }
>>
>>
>> Thank you.
>>
>> Ignacio.
>
>
>

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"OrientDB" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to