Category : singleton

Inspired Web Development

Tim Sommer
Thread-safe singletons in .NET

Thread-safe singletons in .NET

Lets take a look at (static) constructors, thread-safety and static singletons.

Field initialization

Let's start by examining how field initialization works in .NET.

Let's say you have the following code:

public class Program 
{
  // field declaration and initialization
  private int i = 5;

  public Program () 
  {
    // do ctor
Read More