TSingleton = class
strict private
constructor Create;
class var
FInstance:TSingleton;
public
class function GetInstance: TSingleton;
procedure FreeInstance;
end;
implementation
constructor TSingleton.Create;
begin
inherited;
end;
class function TSingleton.GetInstance: TSingleton;
begin
If FInstance = nil Then
begin
FInstance := TSingleton.Create();
end;
Result := FInstance;
end;
procedure TSingleton.FreeInstance;
begin
FInstance:=nil;
end;