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

interface

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

type
  tmythread = class(TThread)
  private
    { Private declarations }
    counter:tedit;
    count:integer;
  protected
    procedure Execute; override;
    public
    constructor Create(lb:tedit);
  end;

implementation
uses unit1;

{ 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 }

constructor tmythread.Create(lb:tedit);
begin
counter:=lb;
count:=1;
inherited create(true);
end;

procedure tmythread.Execute;
begin
  { Place thread code here }
  repeat
  count:=count+1;
  with Critical do begin
  enter;
  counter.Text:=inttostr(count);
  leave;
  end;
  until count=1000;
  end;

end.
Соседние файлы в папке prob4_1
  • #
    02.05.20141 Кб21mythrd.~pas
  • #
    02.05.20142 Кб21mythrd.dcu
  • #
    02.05.20141 Кб22mythrd.pas
  • #
    02.05.2014184 б21Proj.~dpr
  • #
    02.05.2014386 б22Proj.cfg
  • #
    02.05.20141 Кб22Proj.dof
  • #
    02.05.2014211 б21Proj.dpr
  • #
    02.05.2014876 б21Proj.res