package com.jerry.design.singleton;
public class Test {
public static void main(String[] args) {
for(int i=0;i<=10;i++){
System.out.println(FullSingle.getIntance());
System.out.println(HungrySingle.getIntance());
}
// com.jerry.design.singleton.FullSingle@3487a5cc
// com.jerry.design.singleton.HungrySingle@eb42cbf
// com.jerry.design.singleton.FullSingle@3487a5cc
// com.jerry.design.singleton.HungrySingle@eb42cbf
// com.jerry.design.singleton.FullSingle@3487a5cc
// com.jerry.design.singleton.HungrySingle@eb42cbf
// com.jerry.design.singleton.FullSingle@3487a5cc
// com.jerry.design.singleton.HungrySingle@eb42cbf
// com.jerry.design.singleton.FullSingle@3487a5cc
// com.jerry.design.singleton.HungrySingle@eb42cbf
// com.jerry.design.singleton.FullSingle@3487a5cc
// com.jerry.design.singleton.HungrySingle@eb42cbf
// com.jerry.design.singleton.FullSingle@3487a5cc
// com.jerry.design.singleton.HungrySingle@eb42cbf
// com.jerry.design.singleton.FullSingle@3487a5cc
// com.jerry.design.singleton.HungrySingle@eb42cbf
// com.jerry.design.singleton.FullSingle@3487a5cc
// com.jerry.design.singleton.HungrySingle@eb42cbf
// com.jerry.design.singleton.FullSingle@3487a5cc
// com.jerry.design.singleton.HungrySingle@eb42cbf
// com.jerry.design.singleton.FullSingle@3487a5cc
// com.jerry.design.singleton.HungrySingle@eb42cbf
}
}
总结: 保持单jvm下的唯一实例。