unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm1 = class(TForm)
Button1: TButton;
Edit1: TEdit;
Button2: TButton;
Memo1: TMemo;
Memo2: TMemo;
Edit2: TEdit;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
n,f,i:integer;
ThreadHandle: THandle;
ID:DWord;
implementation
procedure Inkrement(var n:integer);
var r:integer;
begin
for r:=n to n+n do
begin
n:=n+1;
end;
end;
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
begin
n:=strtoint(edit1.text);
f:=strtoint(edit2.Text);
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
//memo1.SelText:=inttostr(Inkrement(n));
ResumeThread(ThreadHandle);
ThreadHandle:=createthread(nil,0,@Inkrement,@n,CREATE_SUSPENDED,ID);
//ThreadHandle.Terminate ;
//TerminateThread(ThreadHandle);
//ThreadHandle.free;
suspendthread(ThreadHandle);
for i:=1 to f do
memo1.SelText:=floattostr(createthread(nil,0,@Inkrement,nil,CREATE_SUSPENDED,ID));
for i:=f downto 1 do
memo2.SelText:=floattostr(createthread(nil,0,@Inkrement,nil,0,ID));
end;
End.