Добавил:
Studfiles2
Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз:
Предмет:
Файл:Реферат - Потоки / lab4thread / primlab4 / thrd
.pas unit thrd;
interface
uses
Classes;
type
tmythread = class(TThread)
private
{ Private declarations }
protected
procedure Execute; override;
public
Count : Integer;
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 tmythread.UpdateCaption;
begin
Form1.Caption := 'Updated in a thread';
end; }
{ tmythread }
procedure tmythread.Execute;
Var
I, Total, Avg : Integer;
begin While True Do Begin Total := 0;
For I := 1 To 10 Do
Inc ( Total, Random( Maxint ));
Avg := Avg Div 10;
Inc( Count ) ;
End;
end;
end.
interface
uses
Classes;
type
tmythread = class(TThread)
private
{ Private declarations }
protected
procedure Execute; override;
public
Count : Integer;
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 tmythread.UpdateCaption;
begin
Form1.Caption := 'Updated in a thread';
end; }
{ tmythread }
procedure tmythread.Execute;
Var
I, Total, Avg : Integer;
begin While True Do Begin Total := 0;
For I := 1 To 10 Do
Inc ( Total, Random( Maxint ));
Avg := Avg Div 10;
Inc( Count ) ;
End;
end;
end.