delphiにおける臨界操作方法
1177 ワード
var
FLock:TRTLCriticalSection; //
begin
InitializeCriticalSection(FLock); //
EnterCriticalSection(FLock); //
LeaveCriticalSection(FLock); //
DeleteCriticalSection(FLock);//
end;
//CLASS
TRegGroups = class
private
.............
FLock: TRTLCriticalSection;
................
public
...........
constructor Create;
destructor Destroy; override;
procedure Lock;
procedure Unlock;
................
end;
var
RegGroups: TRegGroups;
constructor TRegGroups.Create;
begin
inherited Create;
................
InitializeCriticalSection(FLock);
.....................
end;
destructor TRegGroups.Destroy;
begin
DeleteCriticalSection(FLock);
.......................
inherited;
end;
procedure TRegGroups.Lock;
begin
EnterCriticalSection(FLock);
end;
procedure TRegGroups.Unlock;
begin
LeaveCriticalSection(FLock);
end;