T
- The type of the object.public class Singleton<T> extends Object implements Serializable
Modifier and Type | Field and Description |
---|---|
private static Map<Class<?>,Object> |
instancePool
Lazy-evaluated instance pool of all the classes.
|
private Factory<? extends T> |
objFactory
Factory for creating a new instance if there is not instance in
the pool
of class T.
|
private static long |
serialVersionUID
|
private Class<? extends T> |
type
Class T.
|
Constructor and Description |
---|
Singleton(Factory<U> objFactory,
Class<U> type)
Create a singleton manager of specified class T.
|
Modifier and Type | Method and Description |
---|---|
private void |
checkPool()
Check existence of the instance pool.
|
T |
getInst()
Get an instance of class T.
|
private static final long serialVersionUID
private static volatile Map<Class<?>,Object> instancePool
private final Factory<? extends T> objFactory