unit ThrdUnit;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  ComCtrls, StdCtrls, ExtCtrls,thrd;

type
  TForm1 = class(TForm)
    Edit1: TEdit;
    Edit2: TEdit;
    Timer1: TTimer;
    Label1: TLabel;
    Label2: TLabel;
    TrackBar1: TTrackBar;
    TrackBar2: TTrackBar;
    Label3: TLabel;
    Label4: TLabel;
    procedure Timer1Timer(Sender: TObject);
    procedure FormCreate(Sender: TObject);
    procedure TrackBar1Change(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
Thread1, Thread2: TSimpleThread;
  end;

var
  Form1: TForm1;

implementation

{$R *.DFM}

procedure TForm1.Timer1Timer(Sender: TObject);
begin
  Edit1.Text := IntToStr( Thread1.Count );
  Edit2.Text := IntToStr( Thread2.Count );
  Thread1.Count := 0;
  Thread2.Count := 0;
end;

procedure TForm1.FormCreate(Sender: TObject);
begin
  Thread1 := TSimpleThread.Create( False );
  Thread1.Priority := tpLowest;
  Thread2 := TSimpleThread.Create( False );
  Thread2.Priority := tpLowest;
end;

procedure TForm1.TrackBar1Change(Sender: TObject);
var  I : Integer;
  Priority : TThreadPriority;
begin
  Priority := tpLowest;
  For I := 0 To ( Sender as tTrackBar ).Position - 1
  Do
   inc( Priority );
  If Sender = TrackBar1
  Then
   Thread1.Priority := Priority
  Else
   Thread2.Priority := Priority;
end;

end.
