Advertisement
Guest User

Untitled

a guest
Aug 27th, 2016
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.37 KB | None | 0 0
  1. public class Main
  2. {
  3.     public static void main(String[] args)
  4.     {
  5.         Singleton s = Singleton.getInstance();
  6.     }
  7. }
  8.  
  9. final class Singleton {
  10.     private static Singleton instance = null;
  11.     private Singleton() {}
  12.    
  13.     public static synchronized Singleton getInstance() {
  14.         if (instance == null) instance = new Singleton();
  15.         return instance;
  16.     }
  17. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement