What are the real world applications of the singleton pattern?

后端 未结 10 557
南旧
南旧 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:07

    Assuming your question is in the title:

    I once worked with a COM object that could only have one instance per server. We exposed it to the entire ASP.NET application through a singleton.

提交回复
热议问题