title: singleton class design in java for creating only 10 instances only
body: <p>I have to create a singleton class and besides this I have to make sure that not more than 
  10 instances of the class to be created the moment it go create the 11 instance it should throw the exception , i have come up with the below design pls advise is it correct te only issue seems to me is where it will throw the exception , please advise .</p>
  
  <pre><code>public final class LazySingleton {
      private static volatile LazySingleton instance = null;
  
  
       private int counter = 0; // use to track the count of instance 
  
      // private constructor
      private LazySingleton() {
      }
  
      public static LazySingleton getInstance() {
          if (instance == null || counter&lt;=10) {
              synchronized (LazySingleton.class) {
                  instance = new LazySingleton();
                  counter ++;
              }
          }
          return instance;
      }
  }
  </code></pre>