Using Synchronized keyword in Singleton Design Pattern
Below is a code of a singleton design pattern. Got some doubt mentioned at the bottom.
public class SingleTon implements Cloneable
private static SingleTon singleTonInstance;
public static synchronized SingleTon getInstance()
if (singleTonInstance == null)
singleTonInstance = new SingleTon();
protected Object clone() throws CloneNotSupportedException
throw new CloneNotSupportedException();
Statement : If getInstance() is called by thousand threads at a time and lets say getInstance() takes 1 sec for each execution; then it takes 1000 sec for all the threads to complete.
Question : What could be the solution to this?