Q
qiubole
Unregistered / Unconfirmed
GUEST, unregistred user!
有人在吗?请教一个多线程问题
在线程中.
while not Terminateddo
begin
try
EnterCriticalSection(SystemSetup.FSaleUpLock);
Self.Synchronize(DoUpdateSale);
finally
LeaveCriticalSection(SystemSetup.FSaleUpLock);
end;
Sleep(100);
end;
在主线程中
while Truedo
begin
TradeData.DNo := IntToStr(GetTickCount);
try
EnterCriticalSection(SystemSetup.FSaleUpLock);
SystemSetup.Log.WriteLog('准备写入TXT');
TextBak.begin
Write;
WriteToTableA;
WriteToTableB;
WriteToTableC;
SystemSetup.Log.WriteLog('准备关闭Txt备份');
TextBak.EndWirte;
finally
LeaveCriticalSection(SystemSetup.FSaleUpLock);
end;
end;
竟然会死锁,这是怎么回事
在线程中.
while not Terminateddo
begin
try
EnterCriticalSection(SystemSetup.FSaleUpLock);
Self.Synchronize(DoUpdateSale);
finally
LeaveCriticalSection(SystemSetup.FSaleUpLock);
end;
Sleep(100);
end;
在主线程中
while Truedo
begin
TradeData.DNo := IntToStr(GetTickCount);
try
EnterCriticalSection(SystemSetup.FSaleUpLock);
SystemSetup.Log.WriteLog('准备写入TXT');
TextBak.begin
Write;
WriteToTableA;
WriteToTableB;
WriteToTableC;
SystemSetup.Log.WriteLog('准备关闭Txt备份');
TextBak.EndWirte;
finally
LeaveCriticalSection(SystemSetup.FSaleUpLock);
end;
end;
竟然会死锁,这是怎么回事