On 2 February 2013 20:28, Simone Tripodi <[email protected]> wrote: > Hi Lewis! > > please apologise in advance my lack of knowledge on that topic, I have > some minor observations about the code style: > >> >> any23/trunk/api/src/main/java/org/apache/any23/vocab/LKIF_CORE_ACTION.java > > in my humble opinion, this way of naming classes is a little > confusing, since usually it is referred to static constants, I would > replace them with `LkifCoreAction`. > Keep it jut as my opinion, anyway ;) > >> + public static DOAP getInstance() { >> if(instance == null) { >> instance = new DOAP(); >> } >> return instance; >> } > > this pattern is not thread safety, immagine 2 (or more) threads access > to `getInstance()` method simultaneously, `instance` would be > initialised more than once; we have 2 options: > > * initialise `instance` by default; > > or, if you want to keep the lazy initialisation: > > * synchronise all `getInstance()` methods.
As far as I know, it is not vital for there to be a single instance for OpenRDF URIs, as equality for URIs is not object equality. Therefore, it should not matter whether there are two or more copies of the "instance" available as equality is preserved for the multiple objects that would be created. The current pattern provides late initialisation, without requiring synchronisation which would slow down the application without cause. Cheers, Peter
