Anonymous user
Singleton: Difference between revisions
→Thread-safe
Line 300:
===Thread-safe===
Double-checked locking
only use with Java 1.5+
<java>
class Singleton
{
private static Singleton myInstance;
public static
{
if (myInstance == null)
if (myInstance == null)
myInstance = new Singleton();
return myInstance;
|