Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 additions and 0 deletions
16
Task/Singleton/C-sharp/singleton-1.cs
Normal file
16
Task/Singleton/C-sharp/singleton-1.cs
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
public sealed class Singleton1 //Lazy: Yes ||| Thread-safe: Yes ||| Uses locking: Yes
|
||||
{
|
||||
private static Singleton1 instance;
|
||||
private static readonly object lockObj = new object();
|
||||
|
||||
public static Singleton1 Instance {
|
||||
get {
|
||||
lock(lockObj) {
|
||||
if (instance == null) {
|
||||
instance = new Singleton1();
|
||||
}
|
||||
}
|
||||
return instance;
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue