unit Unit1;<br><br>interface<br><br>uses<br> Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,<br> Dialogs, StdCtrls,printers;<br><br>type<br> TForm1 = class(TForm)<br> Button1: TButton;<br> Memo1: TMemo;<br> Button2: TButton;<br> procedure Button1Click(Sender: TObject);<br> procedure Button2Click(Sender: TObject);<br> private<br> { Private declarations }<br> public<br> { Public declarations }<br> end;<br><br>var<br> Form1: TForm1;<br><br>implementation<br> uses Unit2;<br>{$R *.dfm}<br><br>procedure TForm1.Button1Click(Sender: TObject);<br>var<br> newthread:TtestThred;<br>begin<br> newthread:=TtestThred.create(false);<br>end;<br><br>procedure TForm1.Button2Click(Sender: TObject);<br>begin<br> showmessage('dddd');<br>end;<br><br>end.<br>unit Unit2;<br><br>interface<br><br>uses<br> Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,<br> Dialogs, StdCtrls;<br><br>type<br> TtestThred = class(TThread)<br> private<br> { Private declarations }<br> protected<br> procedure Execute; override;<br> end;<br><br>implementation<br> uses unit1;<br>{ Important: Methods and properties of objects in VCL or CLX can only be used<br> in a method called using Synchronize, for example,<br><br> Synchronize(UpdateCaption);<br><br> and UpdateCaption could look like,<br><br> procedure TtestThred.UpdateCaption;<br> begin<br> Form1.Caption := 'Updated in a thread';<br> end; }<br><br>{ TtestThred }<br><br>procedure TtestThred.Execute;<br>var<br> i:integer; <br>begin<br> { Place thread code here }<br> for i:=1 to 200 do<br> begin<br> form1.memo1.lines.add(inttostr(i));<br> sleep(500);<br> end;<br>end;<br><br>end.