Skip to content

Tag: singleton

Having issues calling a decorator method (Java)

Working on a group project that is essentially a text-based Pokemon rip-off. My classmates and I were given a UML to work from so I can’t accept any solutions that would add methods or change their parameters. But essentially the issue we’re running into is this: There is a singleton PokemonGenera…

Thread Safe singleton class

I wrote a below Singleton class. I am not sure whether this is thread safe singleton class or not? Can anyone help me with this? Any thoughts on my above Singleton class will be of great help. Updated Code:- I am trying to incorporate Bohemian suggestion in my code. Here is the updated code, I got- Can anyone…

Singleton using AtomicReference

Is it correct implementation of lazy-initializing singleton using AtomicReference? If no – what are the possible issues? Answer No, this is bad: Using an AtomicReference is a nice idea, but it won’t work because Java doesn’t have lazy evaluation. The classic post 1.5 singleton methods are: E…