On the singleton 'getter', add 'synchronized' for thread safety
otherwise, findbugs will say something like "Incorrect lazy initialization of static field ..."
More explanation:
http://www.ibm.com/developerworks/java/library/j-dcl/index.html
http://en.wikipedia.org/wiki/Singleton_pattern
Thursday, September 22, 2011
Private Constructor
http://www.javapractices.com/topic/TopicAction.do?Id=40
If the programmer does not provide a constructor for a class, then the system will always provide a default, public no-argument constructor. To disable this default constructor, simply add a private no-argument constructor to the class. This private constructor may be empty.
In these cases, the lack of an accessbile constructor says to the caller : "There are no use cases for this class where you need to build an object. You can only use static items. I am preventing you from even trying to build an object of this class."
If the programmer does not provide a constructor for a class, then the system will always provide a default, public no-argument constructor. To disable this default constructor, simply add a private no-argument constructor to the class. This private constructor may be empty.
In these cases, the lack of an accessbile constructor says to the caller : "There are no use cases for this class where you need to build an object. You can only use static items. I am preventing you from even trying to build an object of this class."
Friday, September 16, 2011
64bit Ubuntu won't run java
As of Ubuntu 10.04 LT - the Lucid Lynx
you can't run a 32 bit jre on it, will tell you something like
exec: 1: ../../../bin/java: not found
In fact, 32 bit eclipse won't work either, and imaginable many other 32bit applications
you can't run a 32 bit jre on it, will tell you something like
exec: 1: ../../../bin/java: not found
In fact, 32 bit eclipse won't work either, and imaginable many other 32bit applications
Subscribe to:
Posts (Atom)