class MyClass { private static volatile Resource resource; public static Resource getInstance() { if(resource == null)
first of all, having a Singleton this way, you are essentially creating a global object which is a bad practice. I reckon you use Enums instead.