Created
February 18, 2016 06:38
-
-
Save yannick/fbe41c3c0483394fd064 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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