一个可观察的类可以被构造为单例吗? [英] Can an observable class be constructed as a singleton?
本文介绍了一个可观察的类可以被构造为单例吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
解决方案
我以前做过,没有任何问题,正是因为我使用了单身人士。
模式是使用它。
I'm making a program in Java with the Observer pattern (with the help of the Java API). If some of the observables had more than one instance, the program could crash. Should I implement them as singleton? Is it recommended?
解决方案
I did it before and didn't have any problems exactly because I used a singleton. The pattern is there to use it.
这篇关于一个可观察的类可以被构造为单例吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文