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

interface

uses
Classes,Graphics,Windows,SysUtils,StdCtrls,syncobjs;

type
tmythread = class(TThread)
private
{ Private declarations }
protected
procedure Execute; override;
public
Count : Integer;
s:string;
end;

implementation

uses trd;

{ 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, ob, sr : Integer;
begin
if waitforsingleobject(mut,infinite)=wait_object_0 then
begin
While True Do Begin ob := 0;
For i := 1 To 10 Do
//Inc ( ob, Random( Maxint ));
inc(ob,round(sqrt(abs(sin(i)))));
sr := sr Div 10;
Inc( Count ) ;
s:='Hello from threadland';
releasemutex(mut);
end;
// with Critical do begin
// enter;
//showmessage(form1.Edit3.Handle,WM_Settext,0,integer(pchar(s)));
//leave;
End;
end;
//end;

end.
Соседние файлы в папке mutex4
  • #
    02.05.20141.47 Кб17thrd.dcu
  • #
    02.05.20141.13 Кб17thrd.pas
  • #
    02.05.20141.02 Кб17thrd.~pas
  • #
    02.05.20145.28 Кб17trd.dcu
  • #
    02.05.201451 б17trd.ddp
  • #
    02.05.20142.47 Кб18trd.dfm
  • #
    02.05.20141.92 Кб17trd.pas