高手sapphire的回答:
padlock被锁后,其他线程就不能访问了
必须等占用padlock的线程解锁后 才能访问
主要用于线程安全,保护static单体
public sealed class Singleton
2{
3 static Singleton instance=null;
4 static readonly object padlock = new object();
5
6 Singleton()
7 {
8 }
9
10 public static Singleton Instance
11 {
12 get
13 {
14 if (instance==null)
15 {
16 lock (padlock)
17 {
18 if (instance==null)
19 {
20 instance = new Singleton();
21 }
22 }
23 }
24 return instance;
25 }
26 }
27}