The moose likes Java in General and the fly likes Core Java Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Reply locked New topic

Core Java

SharajIndia Anand

Joined: Sep 19, 2005
Posts: 2
Identify the problem within this snippet of Java/C# code. (This is not a trick question � there is a potential real problem in using this code)

class Singleton
public static Singleton Instance() {
if (_instance == null)
_instance = new Singleton();
return _instance;
protected Singleton() {}
private static Singleton _instance = null;
shank ram

Joined: Sep 05, 2005
Posts: 22
i think we have had this before ...this is bound to be moved shortly ... check the appropriate forum to post properly.
Barry Gaunt
Ranch Hand

Joined: Aug 03, 2002
Posts: 7729
Is this an "excercise for the student" or do you need links to how to fix this potential multithreading problem?

Ask a Meaningful Question and HowToAskQuestionsOnJavaRanch
Getting someone to think and try something out is much more useful than just telling them the answer.
David O'Meara

Joined: Mar 06, 2001
Posts: 13459

This is duplicate thread. Please ignore it, I'll ask for it to be closed.
I agree. Here's the link:
subject: Core Java
It's not a secret anymore!