dimanche 29 mars 2015

What is mean by thread safe

Hi I've been going through the singleton pattern, But I'm not able to understand how the below code is thread safe :-



public class ThreadSafeSingleton
{
private ThreadSafeSingleton()
{
}

public static ThreadSafeSingleton Instance
{
get { return Nested.instance; }
}

private class Nested
{
static Nested()
{
}

internal static readonly ThreadSafeSingleton instance = new ThreadSafeSingleton();
}
}


Can somebody explain it ? Cheers :)


Aucun commentaire:

Enregistrer un commentaire