Identify the problem within this snippet of Java/C# code implementing Singleton Desig
Q: Identify the problem within this snippet of Java/C# code implementing Singleton Design Pattern. (This is not a trick question, there is a potential real problem in using this code)
Code Java:
class Singleton
{
public static Singleton Instance()
{
if (_instance == null){
_instance = new Singleton();
return _instance;
}
}
protected Singleton() {}
private static Singleton _instance = null;
}
Re: Identify the problem within this snippet of Java/C# code implementing Singleton D
Do you know what the problem is and are just asking it as a challenge to others, or do you need help figuring out what the issue is?
Re: Identify the problem within this snippet of Java/C# code implementing Singleton D
i just need a help desperately...
I have too submit an answer for this but there is no way i am seeing to solve this question......
plz plz help me out plz
Re: Identify the problem within this snippet of Java/C# code implementing Singleton D
Can you explain what the problem is?
Are there error messages?
Does the code not work as expected?
Re: Identify the problem within this snippet of Java/C# code implementing Singleton D
Hint: Consider what would happen if multiple threads tried to call Instance() at the same time and _instance = null.
Re: Identify the problem within this snippet of Java/C# code implementing Singleton D
Quote:
i just need a help desperately...
I have too submit an answer for this but there is no way i am seeing to solve this question......
How I interpret this statement: I have to turn in a homework assignment and can't figure out the answer to this question - please do so for me. Not going to happen. Of course, maybe I am misinterpreting your problem, in which case you should restate it.
That being said, along with helloworld's hint, here's another: inheritance.