请帮看这样的程序,怪啊?

davidTIm 2002-01-17 04:05:28
我想写一个动态的线程,里面指做一件事,我的伪代码如下
unit Unit1;
uses Unit3;

procedure TForm1.DoGoData(var ithreadUseNO:string);
begin
heremycode;
end;
procedure TForm1.btnGoClick(Sender: TObject);
var mainthread1:TMutiThread;
begin
mainthread1:=TMutiThread.Create(false);
mainthread1.iLoop:=strtoint(edUser.text);
mainthread1.Resume;
end;


Unit3
unit Unit4;

interface

uses
Classes;

type
TMutiThread = class(TThread)
private
{ Private declarations }
protected

procedure Execute; override;


public
iLoop:integer;
function GetElapseTime :String;
constructor Create(tf:boolean);
end;

implementation
uses Unit1,Unit3,SysUtils;

{ Important: Methods and properties of objects in VCL or CLX can only be used
in a method called using Synchronize, for example,

Synchronize(UpdateCaption);

and UpdateCaption could look like,

procedure TMutiThread.UpdateCaption;
begin
Form1.Caption := 'Updated in a thread';
end; }

{ TMutiThread }
function TMutiThread.GetElapseTime :String;
begin
end;

constructor TMutiThread.create(tf:boolean);
begin
inherited Create(tf);
end;


procedure TMutiThread.Execute;
var i:integer;
Searcher:array [1..1000]of TMyThread;
begin
// SetLength(Searcher,iLoop);
for i:=1 to iloop do begin


Searcher[i]:=TMyThread.Create(false);
Searcher[i].threadUserID:= inttostr(I);
Searcher[i].resume;
end;
for i:=1 to iloop do begin
Searcher[i].WaitFor;

end;
end; { Place thread code here }


end.

unit Unit2;
interface

uses
Classes;

type
TMyThread = class(TThread)
private
{ Private declarations }
protected


procedure Execute; override;
procedure doData;
constructor Create(tf:boolean);
public
threadUserID:string;
end;

implementation
{ Important: Methods and properties of objects in VCL or CLX can only be used
in a method called using Synchronize, for example,

Synchronize(UpdateCaption);

and UpdateCaption could look like,

procedure TMyThread.UpdateCaption;
begin
Form1.Caption := 'Updated in a thread';
end; }

{ TMyThread }
procedure TMyThread.doData;
begin
form1.DoGoData(threadUserID);

end;
procedure TMyThread.Execute;
begin
Synchronize(doData);
{ Place thread code here }
end;
constructor TMyThread.create(tf:boolean);
begin
inherited Create(tf);
end;


end.
这样合理吗?
...全文
167 10 打赏 收藏 转发到动态 举报
写回复
用AI写文章
10 条回复
切换为时间正序
请发表友善的回复…
发表回复
Bellamy 2002-01-17
  • 打赏
  • 举报
回复
不会!
davidTIm 2002-01-17
  • 打赏
  • 举报
回复
give your idea
davidTIm 2002-01-17
  • 打赏
  • 举报
回复
你是怎么样做的呢?wd2306(木头)
davidTIm 2002-01-17
  • 打赏
  • 举报
回复
wd2306(木头) you can put your code on net ,may be i can help you
wd2306 2002-01-17
  • 打赏
  • 举报
回复
我自己的线程都作错了,看什么看
davidTIm 2002-01-17
  • 打赏
  • 举报
回复
高手们,帮我看一下啦!我要用这样的技术!
davidTIm 2002-01-17
  • 打赏
  • 举报
回复
Give me answer
davidTIm 2002-01-17
  • 打赏
  • 举报
回复
wd2306(木头)你帮我看一下啊!
wd2306 2002-01-17
  • 打赏
  • 举报
回复
我也想知道
davidTIm 2002-01-17
  • 打赏
  • 举报
回复
上面祢补一下,因为太急了! 是这样的,我想做一个动态多线程做一个同一件事情!
上面代码行吗?或者你有更好的方法帮我吗?

828

社区成员

发帖
与我相关
我的任务
社区描述
Delphi 非技术区
社区管理员
  • 非技术区社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧