惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

H
Help Net Security
博客园 - Franky
GbyAI
GbyAI
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
爱范儿
爱范儿
IT之家
IT之家
酷 壳 – CoolShell
酷 壳 – CoolShell
aimingoo的专栏
aimingoo的专栏
博客园_首页
MongoDB | Blog
MongoDB | Blog
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
Recent Announcements
Recent Announcements
Scott Helme
Scott Helme
有赞技术团队
有赞技术团队
M
MIT News - Artificial intelligence
C
CERT Recently Published Vulnerability Notes
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
Jina AI
Jina AI
F
Fortinet All Blogs
N
Netflix TechBlog - Medium
L
LangChain Blog
L
LINUX DO - 最新话题
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
H
Hacker News: Front Page
MyScale Blog
MyScale Blog
P
Palo Alto Networks Blog
G
Google Developers Blog
Google DeepMind News
Google DeepMind News
AI
AI
T
Troy Hunt's Blog
Microsoft Azure Blog
Microsoft Azure Blog
阮一峰的网络日志
阮一峰的网络日志
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
Vercel News
Vercel News
Microsoft Security Blog
Microsoft Security Blog
罗磊的独立博客
S
Secure Thoughts
大猫的无限游戏
大猫的无限游戏
博客园 - 叶小钗
人人都是产品经理
人人都是产品经理
Blog — PlanetScale
Blog — PlanetScale
博客园 - 司徒正美
Apple Machine Learning Research
Apple Machine Learning Research
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
博客园 - 三生石上(FineUI控件)
S
Security @ Cisco Blogs
Cloudbric
Cloudbric
E
Exploit-DB.com RSS Feed
Attack and Defense Labs
Attack and Defense Labs

博客园 - 北溟鱼逍遥游

datepart in ssis Mac再建管理员帐户 [error] option strict on disallow late binding [SSIS 2005]SSIS Error The AcquireConnection method call to the connection manager failed with error code 0xC0202009 [SSIS 2005]the script task can not run this edition of integration service 团队的脊梁 求:C# 中nowarn 的 attribute msn group 转 大师 Proj summary Thinking snippets SQL server 2005 Enterprise Edition can't support AMD sepron 2500+ Can't found the specified domain: Web access LDAP Server - 北溟鱼逍遥游 C++/STL 笔记 经典:自己收藏 Understand office model Close window without alert DataGrid Item auto-generate serial number 给软件开发经理的建议
Singleton
北溟鱼逍遥游 · 2005-03-15 · via 博客园 - 北溟鱼逍遥游

using System;

public sealed class Singleton1
{
 static Singleton1 instance;
 Singleton1(){}
 public static Singleton1 Instance
 {
  get{
  if (instance == null)
  instance = new Singleton1();
  return instance;
 }
 }
}

public sealed class Singleton2
{
 static Singleton2 instance;
 static readonly object padlock = new object();
 
 public static Singleton2 Instance
 {
  get
  {
   lock (padlock)
   {
    if (instance == null)
    instance = new Singleton2();
   }
   return instance;
  }
 }
}

public sealed class Singleton3
{
 static Singleton3 instance;
 static readonly object padlock = new object();
 public static Singleton3 Instance
 {
  get{
  if (instance == null)
  lock(padlock){
  if (instance == null){
  instance = new Singleton3();
 }
}
       return instance;
}
 }
}

public sealed class Singleton4
{
 static readonly Singleton4 instance = new Singleton4();
 static Singleton4(){}
 Singleton4(){}
 
 public static Singleton4 Instance
 {
  get{
  return instance;
 }
}
}

public sealed class Singleton5
{
 Singleton5(){}
 
 public static Singleton5 Instance
 {
  get{
  return Nested.instance;
 }
}
 
 class Nested{
 static Nested(){}
 internal static readonly Singleton5 instance = new Singleton5();
 }
}