Skip to content

Instantly share code, notes, and snippets.

@yannick
Created February 18, 2016 06:38
Show Gist options
  • Select an option

  • Save yannick/fbe41c3c0483394fd064 to your computer and use it in GitHub Desktop.

Select an option

Save yannick/fbe41c3c0483394fd064 to your computer and use it in GitHub Desktop.
class MySingleton
{
private this()
{
}
private static bool instantiated_;
private __gshared MySingleton instance_;
static MySingleton get()
{
if (!instanciated_)
{
synchronized (MySingleton.classinfo)
{
if (!instance_)
{
instance_ = new MySingleton();
}
instantiated_ = true;
}
return instance_;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment