Here you can find the source of getSingleInstance(Class
public static <T> T getSingleInstance(Class<T> classType) throws Exception
//package com.java2s; // Licensed under the Apache License, Version 2.0 (the "License"); import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentMap; public class Main { private static ConcurrentMap<Class, Object> instanceMap = new ConcurrentHashMap<Class, Object>(); public static <T> T getSingleInstance(Class<T> classType) throws Exception { T instance = null;//from w ww . j a va 2s . c om if (instanceMap.containsKey(classType)) { instance = (T) instanceMap.get(classType); } else { instance = classType.newInstance(); instanceMap.put(classType, instance); } return instance; } }