Hi John,

On 18 November 2012 23:09, John May <johnmay@ebi.ac.uk> wrote:
Hi All,

I found two questions regarding this current code from IChemObject. They aren't bugs but it would be useful to have opinions.

if (properties == null)
    properties = new LinkedHashMap<Object, Object>();
return properties;

https://gist.github.com/4107408

This code allows lazy initialisation - so every ChemObject doesn't have a map unless it needs it. However it is not thread safe - it is very possible to have one thread put properties into a map which is then replaced by a different map. Also LinkedHashMap takes more memory then a normal HashMap as there is a double linked list running through the entires. 

1. should lazy initialisation be thread safe? There is a pattern to do this which minimises the performance cost of synchronising. 

Preferably yes, should be thread safe.
 
2. can LinkedHashMap be replaced with HashMap? There are very few times you want the order of insertion in a map, currently properties are predominately used as a general property store.

I think so. Do we know the cases where the order is important ?

Regards,
Nina 
me John May | Predoctoral Student – Chemoinformatics and Metabolism
European Bioinformatics Institute, Wellcome Trust Genome Campus, Hinxton, Cambridge, CB10 1SD, UK
johnmay@ebi.ac.uk | +44–(0) 1223 49 2603


------------------------------------------------------------------------------
Monitor your physical, virtual and cloud infrastructure from a single
web console. Get in-depth insight into apps, servers, databases, vmware,
SAP, cloud infrastructure, etc. Download 30-day Free Trial.
Pricing starts from $795 for 25 servers or applications!
http://p.sf.net/sfu/zoho_dev2dev_nov
_______________________________________________
Cdk-devel mailing list
Cdk-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/cdk-devel