多线程并发问题TThreadList………… ( 积分: 50 )

  • 主题发起人 主题发起人 zqy29
  • 开始时间 开始时间
Z

zqy29

Unregistered / Unconfirmed
GUEST, unregistred user!
procedure TFrm_Main.N101Click(Sender: TObject);
var
MMS_Create: TMMSPorduce;
SendStr: string;
Loglst: TStringList;
CliSkt: TClientSocket;
ClientTrd: TClientThread;
i, SendTimes: integer;
MMS_Out: TMMS_Out;
begin
SendTimes := StrToIntDef(Edit1.Text, 0);
for i := 1 to SendTimesdo
begin
MMS_Out.AuthID := 'xxxxxxxxx';
MMS_Out.TransActionID := 'xxxxxxxxx'
MMS_Out.MMSAction := 'xxxxxxxxx';
MMS_Out.SenderAddress := 'xxxxxxxxx';
MMS_Out.ChargedPartyID := 'xxxxxxxxx';
MMS_Out.DestPhone := 'xxxxxxxxx';
MMS_Out.Cc := '';
MMS_Out.Bcc := '';
MMS_Out.Submit := 'xxxxxxxxx';
MMS_Out.SendPath := 'xxxxxxxxx';
try
CliSkt := GetNewClient;
CliSkt.Active := True;
except
AddInfoToMemo('连接服务器@' + RemoteIP + ':' + IntToStr(RemotePort) + '@失败');
Sleep(1000);
Continue;
end;
try
MMS_Create := TMMSPorduce.Create;
SendStr := MMS_Create.MMSEncode(MMS_Out);
with FThreadList.LockListdo
begin
if Count <
50 then
begin
Loglst := TStringList.Create;
ClientTrd := TClientThread.Create(false, MMS_Out, SendStr, FThreadList, CliSkt, Loglst);
Add(ClientTrd);
end
else
begin
FThreadList.UnlockList;
CliSkt.Free;
Continue;
end;
end;
FThreadList.UnlockList;
finally
MMS_Create.Free;
end;
end;
end;

当并发量达到并超过控制数量50时,则出现程序死锁的现象,这又是为何呢?
 
procedure TFrm_Main.N101Click(Sender: TObject);
var
MMS_Create: TMMSPorduce;
SendStr: string;
Loglst: TStringList;
CliSkt: TClientSocket;
ClientTrd: TClientThread;
i, SendTimes: integer;
MMS_Out: TMMS_Out;
begin
SendTimes := StrToIntDef(Edit1.Text, 0);
for i := 1 to SendTimesdo
begin
MMS_Out.AuthID := 'xxxxxxxxx';
MMS_Out.TransActionID := 'xxxxxxxxx'
MMS_Out.MMSAction := 'xxxxxxxxx';
MMS_Out.SenderAddress := 'xxxxxxxxx';
MMS_Out.ChargedPartyID := 'xxxxxxxxx';
MMS_Out.DestPhone := 'xxxxxxxxx';
MMS_Out.Cc := '';
MMS_Out.Bcc := '';
MMS_Out.Submit := 'xxxxxxxxx';
MMS_Out.SendPath := 'xxxxxxxxx';
try
CliSkt := GetNewClient;
CliSkt.Active := True;
except
AddInfoToMemo('连接服务器@' + RemoteIP + ':' + IntToStr(RemotePort) + '@失败');
Sleep(1000);
Continue;
end;
try
MMS_Create := TMMSPorduce.Create;
SendStr := MMS_Create.MMSEncode(MMS_Out);
with FThreadList.LockListdo
begin
if Count <
50 then
begin
Loglst := TStringList.Create;
ClientTrd := TClientThread.Create(false, MMS_Out, SendStr, FThreadList, CliSkt, Loglst);
Add(ClientTrd);
end
else
begin
FThreadList.UnlockList;
CliSkt.Free;
Continue;
end;
end;
FThreadList.UnlockList;
finally
MMS_Create.Free;
end;
end;
end;

当并发量达到并超过控制数量50时,则出现程序死锁的现象,这又是为何呢?
 
怎么没人理啊?
坚决投诉讼 版主:g622, wjiachun
 
DFW真的太让人失望了。
 
FThreadList.UnlockList;
cliskt.active:=false;//是不是这个原因啊?
CliSkt.Free;
Continue;
 
to:迷糊
这样也是一样的,没有效果。
 
try
...
finally
FThreadList.UnlockList;
end;
 
没碰到过,顶一下
 
好多*****啊
 
DELPHIBBS现在都没人管了吗?
对大富翁论坛有些失望了。
 
你没有想masm说的那样是一下看看会出什么问题吗?
 
楼主,请看你的代码:
try
......
with FThreadList.LockListdo
begin
if Count <
50 then
begin
......
end
else
begin
FThreadList.UnlockList;
CliSkt.Free;
Continue;
end;
end;
FThreadList.UnlockList;
finally
......
end;

“当并发量达到并超过控制数量50时”,你连续执行了两次UnlockList,不“出现程序死锁的现象”才怪。
 
后退
顶部