Beruflich Dokumente
Kultur Dokumente
0
of 0 votes
Answers
0
of 0vote
ummm just look it up? public class Singleton { private static Singleton instance = null; private Singleton() {} public Singleton getInstance() { if (instance == null) instance = new Singleton(); return instance; } }
- Anonymous on November 14, 2008 | Flag
Reply to Comment
0
of 0vote
Reply to Comment
0
of 0vote
and the getInstance just returns 'instance'. That way you're removing all multithreading concerns from the singleton mechanism.
- Sam on October 11, 2009 | Flag
0
of 0 votes
What if there are other variables that need to be present in this class (which is usually the case) and need to be initialized in the constructor. In that case with what values will you initialize the singleton instance statically?
- Apurva on February 06, 2012 | Flag