Y
yellowfish
Unregistered / Unconfirmed
GUEST, unregistred user!
为何以下两种同步方式都无法阻止错误发生?
procedure myThread.execute;
begin
FreeOnTerminate := True;
EnterCriticalSection(CS);
(...数据写入...)
LeaveCriticalSection(CS);
end;
procedure myThread.execute;
begin
if WaitForSingleObject(hMutex,INFINITE)=WAIT_OBJECT_0 then
begin
(...数据写入...)
end;
ReleaseMutex(hMutex);
end;
procedure myThread.execute;
begin
FreeOnTerminate := True;
EnterCriticalSection(CS);
(...数据写入...)
LeaveCriticalSection(CS);
end;
procedure myThread.execute;
begin
if WaitForSingleObject(hMutex,INFINITE)=WAIT_OBJECT_0 then
begin
(...数据写入...)
end;
ReleaseMutex(hMutex);
end;