// 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); }
public void Test() { SingleTonSample sample = SingleTonSample.Instance; sample.Foo(); }
// Start is called before the first frame update void Start() { SingleTonSample single = SingleTonSample.InstanceCreation(); single.DisplayMessage(); }