What are the real world applications of the singleton pattern?

后端 未结 10 534
南旧
南旧 2021-02-01 07:22

Duplicate

On design patterns: When should I use the singleton?

class Singleton
{
    private static Singleton instance;

    private Singleton() {}

             


        
10条回答
  •  时光说笑
    2021-02-01 08:12

    You should use a Singleton when there should only be one instance of an object. However, Misko Hevery has some thoughts on why Singletons are bad!

提交回复
热议问题