Logo 
Search:

Java Answers

Ask Question   UnAnswered
Home » Forum » Java       RSS Feeds
  Question Asked By: Sunil Garg   on Feb 15 In Java Category.

  
Question Answered By: Viola Hanson   on Feb 15

public class  MySingleton {

private static  MySingleton me = new MySingleton();

private MySingleton() {
// do something if you want
}

public static MySingleton getInstance() {
return me;
}

public void  doSomething() {
System.out.println("I am a stupid method");
}
}

This implementation is considered thread safe.

Share: 

 

This Question has 1 more answer(s). View Complete Question Thread

 
Didn't find what you were looking for? Find more on static / singleton Or get search suggestion and latest updates.


Tagged: