单例模式的测试数据 (三)

2014-11-24 10:41:15 · 作者: · 浏览: 2
ong test都屏蔽掉,则得到如下结果:


[java]
=====TestSingleTon1 wrong test=====
=====TestSingleTon1 right test=====
get instance methord...
constructor methord...
false 148669801
get instance methord...
false 148669801
=====TestSingleTon2 wrong test=====
=====TestSingleTon2 right test=====
constructor methord...
get instance methord...
false 1690552137
get instance methord...
false 1690552137

=====TestSingleTon1 wrong test=====
=====TestSingleTon1 right test=====
get instance methord...
constructor methord...
false 148669801
get instance methord...
false 148669801
=====TestSingleTon2 wrong test=====
=====TestSingleTon2 right test=====
constructor methord...
get instance methord...
false 1690552137
get instance methord...
false 1690552137
[plain]
验证不存在才去new的情况

验证不存在才去new的情况

但!是!要!注!意!

真正的单例模式的构造函数用private声明,而不是上面的public,我测试才用public。