多线程!在线等!!! 我写了个多线程的程序,有二个按钮,点第一个先执行主线程程序,点第二个执行辅线程程序,主线程程序执行完后,辅线程程序还在执行,现在我想再执行主线程程序,但这个按钮怎么点都没用,请指点,谢谢! 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 unit Unit1;interfaceuses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls;type Tgame=class(Tthread) constructor create(); end; thread1=class(Tgame) //constructor create(); // procedure execute;override; end; thread2=class(Tgame) // constructor create(); // procedure execute;override; end; TForm1 = class(TForm) Button1: TButton; Button2: TButton; Button3: TButton; procedure Button1Click(Sender: TObject); procedure Button2Click(Sender: TObject); procedure Button3Click(Sender: TObject); private procedure mythreadfunc3(); procedure mythreadfunc4(); { Private declarations } public { Public declarations } end;var Form1: TForm1;implementation{$R *.dfm}procedure mythreadfunc1();vari,j:integer;beginj:=0;for i:=0 to 10000 dobeginj:=j+1; sleep(500);end;end;procedure mythreadfunc();begin mythreadfunc1(); end;constructor tgame.create();begininherited create(false);freeonterminate:=true;end;procedure TForm1.Button1Click(Sender: TObject);varhthread:thandle;thid:dword;beginhthread:=beginthread(nil,0,@mythreadfunc,nil,0,thid);if hthread=0 thenshowmessage('fail');end;procedure TForm1.Button2Click(Sender: TObject);begin mythreadfunc3();end;procedure tform1.mythreadfunc3();vari,j:integer;beginj:=0;for i:=0 to 10000 dobeginj:=j+1;sleep(500);end;end;procedure tform1.mythreadfunc4();vari,j:integer;beginj:=0;for i:=0 to 10000 dobeginj:=j+1;sleep(500);end;end;procedure TForm1.Button3Click(Sender: TObject);begin mythreadfunc4();end;end. thread1=class(Tgame) thread2=class(Tgame)TGame 是一个线程类阿 没看懂!!! thread1=class(Tgame) //constructor create(); // procedure execute;override; end; thread2=class(Tgame) // constructor create(); // procedure execute;override; end;定义了咋不执行啊?那还有什么用! 如何根据 数据库中得出的名称,匹配哪个 radiobutton 选中? 山东招聘DELPHI精英了!!!!!!!!!!!!!!!!!!!!!!! 能不能去掉TWebBrowser的弹出菜单? 怎么给一副图片加水印啊,高手进来 我用ReportMachine设计报表,在页面设置中自定义纸张大小的问题 怎样用readln从文件读数据?在线等 关于使用TADOConnection的事务功能的问题 哪个网站可以在线看足球 //求助,帮小弟看看这个dll错在什么地方!!! 新人多关照 控件处理 在Delphi中,我想对指定目录中的文件进行压缩,请问该如何写?
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;type Tgame=class(Tthread)
constructor create();
end; thread1=class(Tgame)
//constructor create();
// procedure execute;override;
end; thread2=class(Tgame)
// constructor create();
// procedure execute;override;
end;
TForm1 = class(TForm)
Button1: TButton;
Button2: TButton;
Button3: TButton;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure Button3Click(Sender: TObject); private
procedure mythreadfunc3();
procedure mythreadfunc4();
{ Private declarations }
public
{ Public declarations }
end;var
Form1: TForm1;implementation{$R *.dfm}
procedure mythreadfunc1();
var
i,j:integer;
begin
j:=0;
for i:=0 to 10000 do
begin
j:=j+1;
sleep(500);
end;
end;
procedure mythreadfunc();
begin
mythreadfunc1();
end;constructor tgame.create();
begin
inherited create(false);
freeonterminate:=true;
end;
procedure TForm1.Button1Click(Sender: TObject);
var
hthread:thandle;
thid:dword;
begin
hthread:=beginthread(nil,0,@mythreadfunc,nil,0,thid);
if hthread=0 then
showmessage('fail');
end;procedure TForm1.Button2Click(Sender: TObject);
begin
mythreadfunc3();
end;
procedure tform1.mythreadfunc3();
var
i,j:integer;
begin
j:=0;
for i:=0 to 10000 do
begin
j:=j+1;
sleep(500);
end;
end;procedure tform1.mythreadfunc4();
var
i,j:integer;
begin
j:=0;
for i:=0 to 10000 do
begin
j:=j+1;
sleep(500);
end;
end;
procedure TForm1.Button3Click(Sender: TObject);
begin
mythreadfunc4();
end;end.
TGame 是一个线程类阿
thread1=class(Tgame)
//constructor create();
// procedure execute;override;
end; thread2=class(Tgame)
// constructor create();
// procedure execute;override;
end;
定义了咋不执行啊?
那还有什么用!