Добавил:
Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
Скачиваний:
17
Добавлен:
02.05.2014
Размер:
1.11 Кб
Скачать
unit thrdu;

interface

uses
Classes;

type
testthrd = class(TThread)
private
{ Private declarations }
ans:integer;
s:string;
protected
procedure giveans;
procedure gives;
procedure Execute; override;
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 testthrd.UpdateCaption;
begin
Form1.Caption := 'Updated in a thread';
end; }

uses sysutils,main;
{ testthrd }

procedure testthrd.giveans;
begin
mainform.Edit1.Text:=inttostr(ans);
end;

procedure testthrd.gives;
begin
mainform.Edit2.Text:=s;
end;


procedure testthrd.Execute;
var i:integer;
begin
{ Place thread code here }
s:='Hello from threadland';
freeonterminate:=true;
for i:=1 to 10000 do
begin
if terminated then break;
inc(ans,round(abs(sin(sqrt(i)))));
synchronize(giveans);
synchronize(gives);
end;
end;

end.
Соседние файлы в папке synchron
  • #
    02.05.2014386 б18Project1.cfg
  • #
    02.05.20141.11 Кб17Project1.dof
  • #
    02.05.2014195 б17Project1.dpr
  • #
    02.05.2014876 б17Project1.res
  • #
    02.05.20141.71 Кб18thrdu.dcu
  • #
    02.05.20141.11 Кб17thrdu.pas
  • #
    02.05.20141.12 Кб17thrdu.~pas