请教各位网友,问个多线程的问题:(0分)

N

netbug

Unregistered / Unconfirmed
GUEST, unregistred user!
我想在Delphi中设计一个多线程的程序,是当我按一个键时,有两个线程分别往edit中写入数字,
并此数字是自动累加的,请看以下源程序:
type
TMythread1=class(TThread)
procedure counter;
procedure Execute;override;
end;
procedure TMythread1.counter;
var i:integer;
begin
for i:=0 to 1000do
form1.edit1.text:=inttostr(i);
end;
procedure TMythread1.Execute;
begin
synchronize(counter);
end;

type
TMythread2=class(TThread)
procedure counter;
procedure Execute;override;
end;
procedure TMythread2.counter;
var i:integer;
begin
for i:=0 to 1000do
form1.edit2.text:=inttostr(i);
end;
procedure TMythread2.Execute;
begin
synchronize(counter);
end;
procedure TForm1.Button1Click(Sender: TObject);
var
mythread1:TMythread1;
mythread2:TMythread2;
begin
mythread1:=TMythread1.create(false);
mythread2:=TMythread2.create(false);
end;

现在我想问:
1:过程synchronize是表示啥意思(对不起,我有的也是抄的,根本不知啥意思)?
2:我该如何释放线程?是单独写还是写在某个过程中?如是写在某个过程中,请问是写在哪个过程中?
3:我还想再加入一个次控件,是当我按下此按纽时,以上两个线程就被挂起,请问:线程挂起过程
该如何写?
谢谢。
 
你是不是没钱啦?
 
接受答案了.
 

Similar threads

S
回复
0
查看
795
SUNSTONE的Delphi笔记
S
S
回复
0
查看
797
SUNSTONE的Delphi笔记
S
S
回复
0
查看
1K
SUNSTONE的Delphi笔记
S
S
回复
0
查看
933
SUNSTONE的Delphi笔记
S
顶部