publicclassSingleton {
privatestaticSingleton instance;
privateSingleton (){}
publicstaticsynchronizedSingleton getInstance() {
if(instance ==null) {
instance =newSingleton();
}
returninstance;
}
publicclassSingleton {
privatestaticSingleton instance;
privateSingleton (){}
publicstaticsynchronizedSingleton getInstance() {
if(instance ==null) {
instance =newSingleton();
}
returninstance;
}
本文标题:单例模式
本文链接:https://www.haomeiwen.com/subject/ftxccxtx.html
网友评论