多个线程 &nbsp

  • 主题发起人 coolingxyz
  • 开始时间
C

coolingxyz

Unregistered / Unconfirmed
GUEST, unregistred user!
多个线程 *****在线等******(50分)<br />unit mythtead;
interface
uses
Classes, SysUtils, Forms, mystruct, Windows;
type
Tmythread = class(TThread)
private
{ Private declarations }
SbIp: String;
SbPort: Integer;
SbData: String;
// PPFhIp : PstrIp ;
protected
procedure Execute;
override;
Procedure MainMemoShow;
Public
{ Public declarations }
Constructor Create(sSbIp: String;
iSbPort: Integer;
sSbData: String);
end;

implementation
uses main;
{ Tmythread }
Constructor Tmythread.Create(sSbIp: String;
iSbPort: Integer ;sSbData: String);
begin
inherited Create(True);
SbIp := sSbIp;
SbPort := iSbPort;
SbData := sSbData;
// PPFhIP := pPPFhIp;
Resume;
end;

procedure Tmythread.Execute;
begin
{ Place thread code here }
FreeOnTerminate := True;
//线程做完一遍后终止
Synchronize(MainMemoshow);
end;

Procedure Tmythread.MainMemoShow;
begin
frmfh.MemoShow.Lines.Add('Ip:' + SbIp + '端口:' + IntTostr(SbPort) + '返回状态码');
end;

end.


procedure mainform.SpeedButton1Click(Sender: TObject);
var //按了很多次,也不会出错的。为什么呀,照理要出错了呀。
mth : TMyThread;
begin
mth := TMyThread.Create('1234',123,'afdkaf');
end;
 
你的程序没理由出错呀
 

mth := TMyThread.Create('1234',123,'afdkaf');
这里呀,我按了好几次呀,是不是覆盖了。
 
我试试看看。
 
谢谢大家
 
你什么错误
 
mth不会出错的,你的哪个线程是一个在函数内的堆里的类,他自己会释放自己的,
没有理由出错
 
怎么可能会覆盖。
 
每个线程系统都会保留1M(默认)的位置保存他的一些数据,我想覆盖的可能性不大
 
多人接受答案了。
 
顶部