// method untuk men-instance suatu class itu sendiri
 // dengan mengembalikan nilai itu sendiri
 public static SingleTonSample InstanceCreation()
 {
     if (singleTonObject == null)
     {
         lock (lockingObject)
         {
             if (singleTonObject == null)
             {
                 singleTonObject = new SingleTonSample();
             }
         }
     }
     return(singleTonObject);
 }
Exemple #2
0
    public void Test()
    {
        SingleTonSample sample = SingleTonSample.Instance;

        sample.Foo();
    }
Exemple #3
0
    // Start is called before the first frame update
    void Start()
    {
        SingleTonSample single = SingleTonSample.InstanceCreation();

        single.DisplayMessage();
    }