Добавил:
Studfiles2
Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз:
Предмет:
Файл:Реферат - Потоки / prior4 / Unit1
.pas unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls,mythrd,syncobjs;
type
TForm1 = class(TForm)
Button1: TButton;
Edit1: TEdit;
Edit2: TEdit;
Edit3: TEdit;
Edit4: TEdit;
Label1: TLabel;
Label2: TLabel;
Label3: TLabel;
Label4: TLabel;
procedure Button1Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure FormDestroy(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
Critical:TCriticalSection;
var firstthread,secondthread,thirdthread,fourthread:TMythread;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
begin
firstthread:=TMythread.Create(edit1);
firstthread.Priority:=tpHigher;
firstthread.Resume;
secondthread:=TMythread.Create(edit2);
secondthread.Priority:=tpnormal;
secondthread.Resume;
thirdthread:=TMythread.Create(edit3);
thirdthread.Priority:=tplower;
thirdthread.Resume;
fourthread:=TMythread.Create(edit4);
fourthread.Priority:=tpidle;
fourthread.Resume;
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
critical:=Tcriticalsection.Create;
end;
procedure TForm1.FormDestroy(Sender: TObject);
begin
critical.Free;
end;
end.
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls,mythrd,syncobjs;
type
TForm1 = class(TForm)
Button1: TButton;
Edit1: TEdit;
Edit2: TEdit;
Edit3: TEdit;
Edit4: TEdit;
Label1: TLabel;
Label2: TLabel;
Label3: TLabel;
Label4: TLabel;
procedure Button1Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure FormDestroy(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
Critical:TCriticalSection;
var firstthread,secondthread,thirdthread,fourthread:TMythread;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
begin
firstthread:=TMythread.Create(edit1);
firstthread.Priority:=tpHigher;
firstthread.Resume;
secondthread:=TMythread.Create(edit2);
secondthread.Priority:=tpnormal;
secondthread.Resume;
thirdthread:=TMythread.Create(edit3);
thirdthread.Priority:=tplower;
thirdthread.Resume;
fourthread:=TMythread.Create(edit4);
fourthread.Priority:=tpidle;
fourthread.Resume;
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
critical:=Tcriticalsection.Create;
end;
procedure TForm1.FormDestroy(Sender: TObject);
begin
critical.Free;
end;
end.