A
AI_Player
Unregistered / Unconfirmed
GUEST, unregistred user!
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm1 = class(TForm)
Button1: TButton;
Memo1: TMemo;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
MyThread = class(TThread)
private
{ Private declarations }
i,k:integer;
public
constructor Create(ord:integer);
protected
procedure Execute;
override;
procedure show;
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
constructor MyThread.Create(ord:integer);
begin
inherited Create(false);
i:=ord;
k:=0;
FreeOnTerminate:=true;
end;
procedure MyThread.Execute;
begin
while k<100do
begin
synchronize(show);
k:=k+1;
end;
end;
procedure MyThread.show;
begin
{ Place thread code here }
form1.Memo1.Lines:=inttostr(i)+': '+inttostr(k);
end;
procedure TForm1.Button1Click(Sender: TObject);
var j:integer;
begin
for j:=0 to 9do
MyThread.Create(j);
end;
end.
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm1 = class(TForm)
Button1: TButton;
Memo1: TMemo;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
MyThread = class(TThread)
private
{ Private declarations }
i,k:integer;
public
constructor Create(ord:integer);
protected
procedure Execute;
override;
procedure show;
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
constructor MyThread.Create(ord:integer);
begin
inherited Create(false);
i:=ord;
k:=0;
FreeOnTerminate:=true;
end;
procedure MyThread.Execute;
begin
while k<100do
begin
synchronize(show);
k:=k+1;
end;
end;
procedure MyThread.show;
begin
{ Place thread code here }
form1.Memo1.Lines:=inttostr(i)+': '+inttostr(k);
end;
procedure TForm1.Button1Click(Sender: TObject);
var j:integer;
begin
for j:=0 to 9do
MyThread.Create(j);
end;
end.